Fenster erzeugen
-
Hi Leute,
ich lerne erst WinApi. Ich hab hier ein sehr kleinen code, welcher ein fenster erzeugen soll. Das Programm lässt sich problemlos compilieren und auch starten. Leider wird da kein Fenster angezeigt. Was habe ich falch gemacht?
#include <windows.h> LRESULT CALLBACK WindowsProcedure(HWND, UINT, WPARAM, LPARAM); char szClassName[] = "WinAppTest"; int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nShowCmd) { 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 */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowsProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; if (!RegisterClassEx (&wincl)) return 0; hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "win_test1", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 100, /* The programs width */ 100, /* 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 */ ); ShowWindow (hwnd, 0); while(GetMessage(&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } return(messages.wParam); } LRESULT CALLBACK WindowsProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hwnd, message, wParam, lParam); }Für Eure Hilfe wäre ich Euch sehr dankbar
gruss

-
hmm fehler gefunden:
ShowWindow (hwnd, 0);letzter Argument darf nicht 0 sein.
Vielen Dank an alle die sich dennoch bemücht haben
gruss

-
Hi,
ein Fehler liegt zumindst schonmal hier:ShowWindow (hwnd, 0);die 0 ist definiert als SW_HIDE. Nutze besser SW_SHOW

Gruss,
DeSoVoDaMu
-
Danke für Deine Antwort

Das war der Fehler.Gruss