| NeckDeepInSyntaxErrors (49) | |
Example:PostMessage(hwnd, ID_HWND_CLICK, 0, 0)What I wanted to know is, using PostMessage(...) to send a control message (ie, ID_HWND_CLICK) defined within the program (ie, sending a message when a button is clicked), what would I use the wParam and lParam parameters for? | |
|
|
|
| freddie1 (847) | |
|
If its a custom message you are sending (and from your example it looks like it is), then what you put in or fail to put in the WPARAM and LPARAM parameters doesn't matter. Leave them zero if it suits you. Their purpose is to efficiently transfer application specific data. If there isn't any in the context of what you are doing, then there isn't any. On the other hand, if all you are wanting to do is simulate a button click message, then send a WM_COMMAND message, and fill in the WPARAM and LPARAM parameters with the correct data pertaining to a button click. Windows has macros like MAKEDWORD (that might not be spelled right) that helps put both 'packets' together, i.e., the lo and hi word 16 bit parts of each parameter. Maybe its just me, but I tend to use SendMessage() more frequently than PostMessage(). | |
|
|
|
| modoran (1245) | |
|
You NOT need to send ID of the control (ID_HWND_CLICK as you seem to do in this example), you send custom message itself (like WM_USER + 1 for example). wparam and lparam can have any value you want. If you want to send a message to a control, use his HWND instead (in your case I assume hwnd is the HWND of main dialog). It may be better to explain exactly what you want to do, a custom message is rarely needed. | |
|
|
|
| NeckDeepInSyntaxErrors (49) | |||
|
Okay, I'm fairly new (in terms of experience) to Win32. The program will be a "Virtual Library". It will allow the user to "upload" ebooks (essentially move the ebooks to a folder within the program's directory), add information about each one, display them and open them in their default external programs to read. (I'm aware there are programs like this, probably much better than mine will be, out there. This is a personal gift though, and it would mean more that I wrote out each line myself) XD Also, I will probably split the project into multiple files, or move a lot to resource files, once it gets bigger but for now I am doing mostly everything dynamically (not sure if that's bad or not). The whole source code is a little too long for one post (but by no means anywhere near complete. I still have A LOT to do), so I'll split between two posts, and add the reason behind my question at the end of the second post, so here it is: (Okay, my "Dialog" is not a conventional dialog window, I know)
| |||
|
|
|||
| NeckDeepInSyntaxErrors (49) | |||
The reason I asked this question, is because the second window, or "Dialog" if you will, should take on different looks (display different controls, etc) based on the reason it was called. Basically, I wanted to be able to send a message to the "Dialog" but include information which could be pulled out in the WM_INITDIALOG/WM_CREATE section of the second window to determine which "look" it will take on and display the relative controls. Or, should I just split the second window, and give each "look" it's own window and message loop? | |||
|
|
|||
| NeckDeepInSyntaxErrors (49) | |
|
Sorry for leaving in all of the stuff not really important to the question, but for the sake of showing you exactly what I'm working with so far, I left it XD I have tried compiling it, and it does run so far. So far, everything is exactly as it should be. The bitmaps used with the static controls are essentially wood grain textures used to simulate a bookshelf look XD The large amount of IDC_MAIN_Axx IDs will be buttons, with book covers as bitmaps placed over them for each of the books displayed, and when clicked will open the second window, showing the information for the book. The options to change information for the book, as well as open it will all be handled in the second window, with the first essentially being there for "looks" XD I wanted to be able to use PostMessage(...) to send messages from window one to window two. When window two is called, it will check to see if the class is registered and the window is created to avoid reregistering it, or recreating it, since it will act as a "modeless dialog". As I've mentioned, the second window will display different controls in different areas depending on why it was called (which is the reason behind asking what would the wParam and lParam paramaters be used for) so I could find a way to pass in additional information on which look it should attain if it is not already open, or if it is already open, update it on which look it should change to (depending upon the message sent). There may be an easier way to do this (and as I've said, I'm fairly new to using the Win32 API, so if there is please let me know). Thank you for your time and responses. - John | |
|
|
|
| NeckDeepInSyntaxErrors (49) | ||
Interesting... May I please just put in a request to have this thread deleted (as there is nothing worth keeping)? I'll just employ a trial error system until I get it. | ||
|
|
||
| EssGeEich (1009) | |
| Nah, you can't delete a thread. They just stay up almost forever, in case they're useful for someone else. | |
|
|
|