• Advertisement

Archived

This topic is now archived and is closed to further replies.

Windows stuff

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a good place to find functions for simple windows tasks? I''ve done such things as use text/edit boxes using GetDlgItemText(..) and SetDlgItemText(..), but now I''m trying to implement a ListBox or even just a check box, and the help files are driving me somewhat mad with all the information that doesn''t seem to pertain to my needs. So basically, does anyone know if there are similar functions to Set/GetOptions in a list box, or just tell if a check box is marked? I''m using VC++ 6. I''m at the point where I have the resource made, and in the switch(LOWORD(wParam)), I can identify when the list box or check box comes into focus, but can''t figure out the functions I''d use after that. I assume you have to ID the selections somehow. Hope that made sense. Thanks, Brett.

Share this post


Link to post
Share on other sites
Advertisement
Check out "windowsx.h" for various macros pertaining to list boxes. They look like "ListBox_AddLine", "ListBox_DoSomething"... Note the actual message that each macro sends to the window eg. WM_SETTEXT etc... and use that to look up the details pertaining to how to use the control.

Share this post


Link to post
Share on other sites
I reccommend that you get a book if you''re seriously into Win32 Programming.

To add a string to the list box:
  
SendDlgItemMessage(hdwnd, LB_ADDSTRING, "Text", NULL);


When a user selects an item in the list box, you have to test for it under WM_COMMAND with the wParam (I think) as the List Box ID. The lParam tests if it was a double-click or just a selection change. Selection changes can be done via mouse or keyboard so there''s a difference.

I don''t remember anything about check boxes. I usually paste code for this one... hehe. I think that it uses the SendDlgItemMessage(...) too.

Try this:
  
int status = SendDlgItemMessage(hdwnd, BM_GETCHECK, NULL, NULL);
//if that doesn''t work, try CB_GETCHECK



Now status is either checked, unchecked or grayed. I forgot their IDs though.

Changing the status is similar
  
SendDlgItemMessage(hdwnd, BM_SETCHECK, status, NULL);

Share this post


Link to post
Share on other sites
Download the Microsft Platform SDK from MSDN. It is available for free, and it contains a nifty reference for nearly every kind of control you would want to use in Win32.

If you want a book, the most popular Win32 book is "Programming Windows" by Charles Petzold.

Share this post


Link to post
Share on other sites
Thanks for the help, everyone.

For those who may want to know, you add strings to a list box with the following code:

SendDlgItemMessage(hwnd,YOUR_LB_ID,LB_ADDSTRING,0,(LPARAM)"Your String");

It doesn''t work without casting the LPARAM, which was annoying.

Thanks again,
Brett

Share this post


Link to post
Share on other sites

  • Advertisement