🔒 Locked
Winapi ...
Advertisement
Original Post
Okay, there is no error or nothing but the window dosent got away when I quit it // SRC #include LRESULT CALLBACK WndProc (HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lparam); HWND GmaWindow (int SizeX, int SizeY,LPCSTR WindowName,HINSTANCE wndH); int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE pInstance,PSTR cmdc,int cmdshow) { MSG Messages; HWND hWnd = GmaWindow(300,300,"Slugther",hInstance); while(1) { if(GetMessage(&Messages,0,0,0)) { TranslateMessage(&Messages); DispatchMessage(&Messages); } else { } } UnregisterClass("NEXT",hInstance); return Messages.wParam; } LRESULT CALLBACK WndProc (HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lparam) { switch(Msg) { case WM_DESTROY: PostQuitMessage(0); break; case WM_CLOSE: PostQuitMessage(0); break; } return DefWindowProc(hwnd,Msg,wParam,lparam); } HWND GmaWindow (int SizeX, int SizeY,LPCSTR WindowName,HINSTANCE wndH) { HWND WindowSly; WNDCLASSEX wndClassEx = {0}; wndClassEx.cbSize = sizeof(wndClassEx); wndClassEx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndClassEx.hInstance = wndH; wndClassEx.lpfnWndProc = WndProc; wndClassEx.style = CS_VREDRAW | CS_HREDRAW; wndClassEx.lpszClassName = "NEXT"; RegisterClassEx(&wndClassEx); WindowSly = CreateWindowEx(NULL,"NEXT",WindowName,WS_OVERLAPPED, 350, 200 , SizeX, SizeY, 0, 0, wndH, 0); if(!WindowSly) MessageBox(NULL,"Error in registering part of the window","ERROR",MB_OK); UpdateWindow(WindowSly); ShowWindow(WindowSly,1); return WindowSly; } yes it's kinda bad done, but that is cuz I redidit a million times and this is the product. Anyways, the window quits or so it seems, its still active. So when I press Ctrl+Alt+Del and choose process I can see it but not in running processes ? crazy, wacky hack :-) no but please help !
code tags around the whole thing would help...
Faq->tags
also I dont know if it came through copying, but you should really use tabs to make it more viewable
also I dont know if it came through copying, but you should really use tabs to make it more viewable
#include <windows.h>LRESULT CALLBACK WndProc (HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lparam);HWND GmaWindow (int SizeX, int SizeY,LPCSTR WindowName,HINSTANCE wndH);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE pInstance,PSTR cmdc,int cmdshow){MSG Messages;HWND hWnd = GmaWindow(300,300,"Slugther",hInstance);while(1){if(GetMessage(&Messages,0,0,0)){TranslateMessage(&Messages);DispatchMessage(&Messages);}else{}}UnregisterClass("NEXT",hInstance);return Messages.wParam;}LRESULT CALLBACK WndProc (HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lparam){switch(Msg){case WM_DESTROY: PostQuitMessage(0); break;case WM_CLOSE: PostQuitMessage(0); break;}return DefWindowProc(hwnd,Msg,wParam,lparam);}HWND GmaWindow (int SizeX, int SizeY,LPCSTR WindowName,HINSTANCE wndH){HWND WindowSly;WNDCLASSEX wndClassEx = {0};wndClassEx.cbSize = sizeof(wndClassEx);wndClassEx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);wndClassEx.hInstance = wndH;wndClassEx.lpfnWndProc = WndProc;wndClassEx.style = CS_VREDRAW | CS_HREDRAW;wndClassEx.lpszClassName = "NEXT";RegisterClassEx(&wndClassEx);WindowSly = CreateWindowEx(NULL,"NEXT",WindowName,WS_OVERLAPPED,350, 200 , SizeX, SizeY, 0, 0, wndH, 0);if(!WindowSly) MessageBox(NULL,"Error in registering part of the window","ERROR",MB_OK);UpdateWindow(WindowSly);ShowWindow(WindowSly,1);return WindowSly;}
Try calling DestroyWindow when you process WM_CLOSE, or don't process it at all.
Also there appears to be no way out of your event loop. Try adding a break command in your else block.
Hiya, just a little note:
You can just use:
while(GetMessage(&Messages,0,0,0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
I know it isn't anything major, just saves an ever so little bit of typing.
Quote:
while(GetMessage(&Messages,0,0,0) > 0)
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
You can just use:
while(GetMessage(&Messages,0,0,0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
I know it isn't anything major, just saves an ever so little bit of typing.
But it's not correct since GetMessage() will return -1 on an error.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement