home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os2.programmer
- Path: sparky!uunet!darwin.sura.net!gatech!taco!garfield.catt.ncsu.edu!harris
- From: harris@garfield.catt.ncsu.edu (Michael Harris)
- Subject: Re: Problem with checkbox
- Message-ID: <harris.712456950@garfield.catt.ncsu.edu>
- Sender: news@ncsu.edu (USENET News System)
- Organization: North Carolina State University
- References: <1992Jul29.065258.19484@neptune.inf.ethz.ch>
- Distribution: usa, local
- Date: Thu, 30 Jul 1992 00:42:30 GMT
- Lines: 47
-
- ezeller@iiic.ethz.ch (Emil Johann Zeller) writes:
-
- >MRESULT ClientWinProc(HWND hwnd, USHORT msg, MPARAM mp1,
- > MPARAM mp2)
- >{
- > HWND hwndControl;
- ^^^^^^^^^^^^^^^^
-
- This is your problem. You are aware of the fact that EVERY time your window
- proceedure gets a message, these variables are created and then deleted
- when the procedure exits? This is a LOCAL variable. You need global storage.
-
- > case CWPM_CREATE:
- > hwndControl = WinCreateWindow(hwnd, WC_BUTTON, "Beep on WM_PAINT",
- > WS_VISIBLE | BS_AUTOCHECKBOX,
- > cx - 100, cy - 10, 200, 20, hwnd,
- > HWND_TOP, ID_BUTTON, NULL, NULL);
- > case WM_PAINT:
- > if (SHORT1FROMMR(WinSendMsg(hwndControl, BM_QUERYCHECK, NULL, NULL))) WinAlarm(HWND_DESKTOP, WA_NOTE);
- > return(WinDefWindowProc(hwnd, msg, mp1, mp2));
- > break;
-
- When this statement is executed, hwndControl is undefined. Either define your
- variable outside the context of the window procedure, or use the window word
- to store the handle.
-
- Here's another suggestion that is better than the other two. If you change
- your WM_PAINT processing to:
-
- if (SHORT1FROMMR(WinSendMsg( WinWindowFromID(hwnd, ID_BUTTON),
- BM_QUERYCHECK,
- NULL,
- NULL)
- )
- )
- WinAlarm(HWND_DESKTOP, WA_NOTE);
-
- you won't need the variable. WinWindowFromID returns the window handle of
- a window given the window's parent and the unique window id. This will only
- work if all children of hwnd have unique id's. (or at least the window id
- you are querying is unique.)
-
-
- ______________________________________________________________________________
- Michael Harris - harris@catt.ncsu.edu or harris@carvm3.vnet.ibm.com
- System Administrator, Computer & Technologies Theme Program, NC State Univ.
- (My opinions are my own and do not represent those of NCSU or IBM Corporation)
-