|
PowerBASIC Forums
![]() PowerBASIC for Windows
![]() Relationships among messages, controls, and dialogs
|
| next newest topic | next oldest topic |
| Author | Topic: Relationships among messages, controls, and dialogs |
|
Jamal Mazrui Member |
Although I have read and re-read explanations of this topic, I am still having trouble getting a firm conceptual grasp of the relationships among messages, controls, and dialogs. For example, which messages go to the callback procedure of the control, and which to the call back procedure of the dialog? Do some messages initially go to the control procedure, and then go on to the dialog procedure? Do some messages automatically go in the reverse direction: from the dialog to the control? I interpreted some MSDN documentation to say that a window has an internal procedure that is in addition to the procedure one accesses via subclassing. This confused me because I thought subclassing was a means of getting to the message processing done by a control that is not otherwise exposed. How many layers of message-processing procedures are associated with the same window? I have also been confused about when to return True or nonzero after processing a message with custom code, and when to return the opposite. I thought True should be returned if no additional, automatic processing by Windows was desired. I recall reading something about the WM_INIT dialog message, however, that said the opposite, that is, False should be returned by custom code if the initialization tasks are to continue. Related to all this, I wonder when it is best to think of a control as the source of a message, when to think of its parent dialog as the source, when to think of the operating system generally as the source, and when to think of a user action as the source. I realize that I have asked a lot of questions, and that this may be a broad topic. Any conceptual distinctions that can help me categorize and understand the various relationships would be appreciated. Jamal IP: Logged |
|
Michael Mattias Member |
DDT-style or SDK-style programming? There can be some very signficant differences. IP: Logged |
|
Jamal Mazrui Member |
I prefer DDT-style coding, though hope to gain a conceptual framework that incorporates what DDT is doing differently. Certainly though, I would gladly learn a simplified DDT explanation before additional SDK complexities. [This message has been edited by Jamal Mazrui (edited May 16, 2005).] IP: Logged |
|
Chris Boss Member |
Jamal, Windows messages 101: Let's start with how things really work with Windows under the hood ! Windows works basically with just one type of callback procedure Every window class (a specific window type, such as a Button or A Window procedure looks like this:
All Windows work this way, no matter what programming language or If a Window created is of a predefined class, the Window procedure Even Dialogs (aka. DDT or the Windows Dialog engine) have their The only window type that you do have direct access to the window If Dialogs have their Window procedure in the operating system, Easy, the Dialog class has a built in form of subclassing (or better When the Dialog is created it is passed an address to a Dialog This is how Dialogs get a Dialog procedure ! A Dialog procedure does have limits and it is not exactly For one, a Dialog procedure tells the Window procedure whether The problem is that the Dialog procedure can't always return a value For most instances though, the Dialog procedure can handle easily Please note that some messages never get sent to a Dialog procedure, With that said, DDT is based on the Windows Dialog engine, so the rules associated The Dialog procedure is some times refered to as a callback procedure. I am not sure of the original of the term callback, but I think it From my perspective, I have always viewed the term callback as simply Now what DDT refers to as callback functions for controls are They are not even subclass procedures. They are simply functions which the DDT engine callbacks to when it WM_COMMAND Some Controls send this message to the window procedure of their The control callbacks do not have an API counterpart. They are Actually DDT has two levels of rerouting. One is the dialog procedure. In true Windows terms, there is We don't know for sure how DDT works internally, but it is As far as Controls Callback routines, don't think of them like any It would be no different if you wrote your app using CreateWindowEX View the control callback as a form of message redirection ! Yes, you get messages, but the function is not a window procedure It is simply a mechanism to simplify coding for you and thats it. Actually the DDT implimentation is quite efficient and simple.
[This message has been edited by Chris Boss (edited May 16, 2005).] IP: Logged |
|
Jamal Mazrui Member |
Thanks for your response, Chris. I guess I had mistakenly thought that a call back procedure is a window procedure. It still seems to have a similar purpose and operation, even though Cb variables are available inside the procedure without having being passed as message parameters. You said that every window has a single window procedure of the form: Your example function seemed to call another function in the line: Aren't these two message-processing procedures for a single window? I understood you to say that if a DDT dialog has a call back procedure, it is not the true "dialog procedure," which is also not the "window procedure." In what order do these procedures process messages? Is a DDT call back the first to receive a message, followed by the dialog procedure, followed by the window procedure? Which messages go to control call back rather than dialog call back procedures? Does this depend on a WS_NOTIFY style for some controls? As you can tell, my understanding still has a way to go .... <grin> Jamal IP: Logged |
|
Simon Morgan Member |
Jamal For DDT programming, things are somewhat simpler. Messages for all controls go first to the callback procedure for that control (if there is one). Unless that procedure returns FUNCTION=1, the same message then gets passed to the callback procedure for the dialog. Returning FUNCTION=1 tells the DDT engine that you don't want it to do any further processing of the message. This is the opposite of what you need to return in most SDK style callbacks. In most cases it makes no difference what value you return when using DDT. The call to DEFWINDOWPROC in Chris's very thorough response above is never needed in a DDT callback procedure. It simply tells Windows to do its normal thing with this message. A DDT callback is similar in many ways to an SDK-style callback using the Windows Dialog engine, but there are differences because it is being contolled by PB runtime procedures included in the resulting executable file. A DDT callback is also treated differently at compile time, for example by dealing with the CB... functions that are not available to SDK programmers. IP: Logged |
|
Chris Boss Member |
Jamal, I didn't say "every window" has a window procedure, but ... "every window class" has a window procedure ! There is a difference. If I create a window class called "MyClass32" (using RegisterClass) Once the class exists , I could then create ten different windows Most of the examples of window procedures you may see posted in If a second window was created using that window class though, it Now Dialog procedures are different. Since the Dialog class reroutes The dialog class is the only built in window class that does this ! All other window classes (ie. buttons, combobox, listview) have just Knowing this helps one to understand why there is such a thing as As I stated above, the callbacks for controls are simply routines ------------------ IP: Logged |
All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.