cppman Posted October 19, 2006 Share Posted October 19, 2006 (edited) Hi. I've been going through a GUI tutorial for C++, and am having trouble with checking the wnd message to see if my button has been pressed.. Im not too sure how to do it. here is my code: expandcollapse popup#include <windows.h> const char *ClassName = "WndClass"; const char *WndName = "MyWindow"; HWND myButton; LRESULT CALLBACK MessageProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void wndProperties(WNDCLASSEX &WndClsEx, HINSTANCE hInstance) { WndClsEx.cbSize = sizeof(WNDCLASSEX); WndClsEx.style = CS_HREDRAW | CS_VREDRAW; WndClsEx.lpfnWndProc = MessageProc; WndClsEx.cbClsExtra = 0; WndClsEx.cbWndExtra = 0; WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW); WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClsEx.lpszMenuName = NULL; WndClsEx.lpszClassName = ClassName; WndClsEx.hInstance = hInstance; WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); } HWND MakeWindow(char *title, int width, int height, HINSTANCE hInstance) { return CreateWindowEx(0,ClassName,title,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hInstan ce,NULL); } LRESULT CALLBACK MessageProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_DESTROY: PostQuitMessage(WM_QUIT); break; break; //case myButton: // MessageBox(NULL, "Test", "tesT", MB_OK); //break; default: DefWindowProc(hWnd, uMsg, wParam, lParam); break; } } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) { //Inside my windows function MSG Msg; HWND hWnd; WNDCLASSEX WC; wndProperties(WC, hInstance); RegisterClassEx(&WC); HWND myWindow = MakeWindow("my title", 500, 500, hInstance); myButton = CreateWindowEx(0, "BUTTON", "This is my button!", WS_CHILD | WS_VISIBLE, 0, 0, 200, 20, myWindow, (HMENU)100, GetModuleHandle(NULL), NULL); ShowWindow(myWindow,nCmdShow); UpdateWindow(myWindow); while( GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage(&Msg); } } the button im trying to check is the only button, myButton. I'd appreciate any help Edited October 19, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 19, 2006 Share Posted October 19, 2006 This doesn't belong in the AutoIt forums, but you must check for WM_COMMAND and read one of the params for the button. Link to comment Share on other sites More sharing options...
cppman Posted October 19, 2006 Author Share Posted October 19, 2006 This is "Developers" forum.. for "C++ Geeks" to talk. lol. Thanks, works perfect. Miva OS Project Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 20, 2006 Share Posted October 20, 2006 This is AutoIt related C++. Otherwise, you are welcome. Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 20, 2006 Share Posted October 20, 2006 Then why is it a subforum of AutoIt v3? Link to comment Share on other sites More sharing options...
JSThePatriot Posted October 21, 2006 Share Posted October 21, 2006 Then why is it a subforum of AutoIt v3?Because before the source went closed the Dev's discussed things here.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 29, 2006 Share Posted October 29, 2006 I'd love to see the developers forum. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now