Fenster verschwindet plötzlich nach definition einer ID
-
Ja ich will ein About Fenster erstellen, soll aber keine MessageBox sein sondern ein Fenster in dem ich noch was reinpacken kann...
-
Einfach anstatt der MessageBox das Fenster deiner Wahl zu erstellen. So z.B., da wird jetzt das Hauptfenster nochmal erstellt, beim Klick auf den About-Button.
#include <windows.h> #define IDB 4711 /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); HWND hWnd; HWND hAboutDialog; /* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "test", /* Title Text */ WS_OVERLAPPED , /* default window */ GetSystemMetrics(SM_CXSCREEN)/4, //X-Position GetSystemMetrics(SM_CXSCREEN)/4, //Y-Position 600, /* The programs width */ 200, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nFunsterStil); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hButtonAbout; static HWND hButtonExit; static HWND hButtonGenerate; static HWND hStatic1; switch (message) { case WM_CREATE: { // Creates the Exit-Button hButtonExit = CreateWindow( "button", "&Exit", WS_CHILD | WS_VISIBLE | BS_VCENTER | BS_FLAT , 492, 153, 100, 20, hwnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); // Set the font to windows standart font for Exit-Button SendMessage(hButtonExit, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), MAKELONG(TRUE, 0)); // Creates the Exit-Button hButtonAbout = CreateWindow( "button", "&About", WS_CHILD | WS_VISIBLE | BS_VCENTER | BS_FLAT , 0, 153, 100, 20, hwnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); // Set the font to windows standart font for About-Button SendMessage(hButtonAbout, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), MAKELONG(TRUE, 0)); // Creates the Generate-Button hButtonGenerate = CreateWindow( "button", "&Generate", WS_CHILD | WS_VISIBLE | BS_VCENTER |BS_FLAT , 246, 153, 100, 20, hwnd, (HMENU) IDB, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); // Set the font to windows standart font for Generte-Button SendMessage(hButtonGenerate, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), MAKELONG(TRUE, 0)); // Creates the Static1-Control hStatic1 = CreateWindow( "static", "Serial invalid, shmocks !", WS_CHILD | WS_VISIBLE | BS_CENTER , 20, 20, 170, 20, hwnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); // Set the font to windows standart font for Static1-Button SendMessage(hStatic1, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), MAKELONG(TRUE, 0)); return 0; } case WM_COMMAND: { if (lParam == (LPARAM)hButtonExit) { if (HIWORD(wParam) == BN_CLICKED) SendMessage(hwnd, WM_CLOSE, 0, 0); } if (lParam == (LPARAM)hButtonAbout) { if (HIWORD(wParam) == BN_CLICKED) { CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "test", /* Title Text */ WS_OVERLAPPEDWINDOW | WS_VISIBLE , /* default window */ 20, //X-Position 20, //Y-Position 100, /* The programs width */ 100, /* and height in pixels */ hWnd, /* The window is a child-window to desktop */ NULL, /* No menu */ GetModuleHandle(NULL), /* Program Instance handler */ NULL /* No Window Creation data */ ); } } break; } SendMessage(hButtonGenerate, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), MAKELONG(TRUE, 0)); case WM_CLOSE: { PostQuitMessage(0); return 0; } case WM_DESTROY: PostQuitMessage (0); break; default: return DefWindowProc (hwnd, message, wParam, lParam); } }
-
Jo super das klappt schon, obwohl ich dachte das ich das schonmal probiert hätte, hmm
Und wie mach ich nun ein komplett neues Fenster auf ?
-
Machst dir einfach eine neue Fensterklasse fertig mit neue WndProc. Also WNDCLASSEX Struktur ausfüllen, Registrieren (RegisterClassEX) und dann kannst du auch schon ein neues Fenster davon erstellen.
-
Na wenn's weiter nichts ist !
Ich glaub ich muss mir das nochmal genauer anschauen, irgendwie steig ich noch nicht ganz durch.
Trotzdem danke,
OHPen
-
Hol dir mal das Buch hier!
http://www.amazon.de/exec/obidos/ASIN/3860634879/qid=1042414564/sr=2-1/ref=sr_aps_prod_1_1/302-5666634-0055254
-
Kannst du mir sonst noch Bücher empfehlen ?
Das hab ich morgen aber in englishGruss
-
Ne, das reicht an Büchern für den Anfang.
Das hab ich morgen aber in english
Ebookzzzzzzzz?
-
Naja, was soll man machen
Die Zeiten sind hart !Bis denne
-
Ja, ist nur scheiße das man am Bildschirm schlecht lange Texte lesen kann. Also ich könnte so nicht lernen. Aber wenn du damit klarkommst. *g*
-
Ich drück mir das fein aus Doppelseitig und dann hab ich auch mein Buch
LOL
-
LOL, wenn das billiger kommt.
Lädst du das als chm Hilfedatei? Wenn ja, wie kann man da alles aufeinmal ausdrucken?
-
Hope es is PDF, aber ich weiß es nicht *.RAR
Muss mich wohl überraschen lassen. Hoffentlich kein HTML, grrr.
-
Meines Wissens treibt sich das nur als CHM Datei im Netz rum. Also für das Programm "HTML Help". Aber hab es ausprobiert - ist ganz easy auszudrucken. Aber viele Seiten.
-
Tausend gehn schon
Oder ich machs einfach in der FH.
-
Na ja, bei mir sind 1000 Seiten schon 1/3 Toner. :p
Also 23 €.
Wieviel würdest du denn an der FH bezahlen?
-
Bezahlen ? ;))))
Na Klar.
Papier was sonst ?
-
Was? Wo gibts denn sowas noch?
Bei uns an der Uni gibt es glaub ich 100 Seiten frei.Wenn das jeder machen würde...wer soll das bezahlen?
-
Da Schröder
Ne ich drück mir pro Woche nur um die 3-4 Bücher aus, nix größes halt.
Naja, bis die Tage dann, und danke für die Hilfe.
Gruss OHPen
-
Bist du eigentlich noch zu retten? Du verschuldest unseren Staat?