News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Superclass controls defined in rc

Started by newAsm, June 29, 2009, 12:24:36 AM

Previous topic - Next topic

newAsm

Hi there,

I am working on a simple microcomputer C-language simulation project. I have a list of instructions which user click to predict the outcome. I have defined the controls in the .rc file (attached with the zip file). I would like to superclass 25 checkbox controls and 64 labels rather than creating 89 subclass routines. In Izelion's tutorial, the superclass is defined during run-time as an example. How would you create a superclass routine when your controls are already defined in a .rc file. I would appreciate the steps I need to take to do this. I created this project using WinAsm and you can view the .rc file in it.

Thanks...newAsm

[attachment deleted by admin]

ToutEnMasm

Hello,
Perhaps a listview with just a list of the instructions (in text format) will be better than this.
If you have such a list , i can show you how to do.

Tedd

You don't need a separate class for each one - use a single class for them all; that class checks the control ID and uses that to look up the instruction to be performed.
Make an array containing the function pointers to each of the instructions, and give each control a sequential ID that indexes into the array. Then when one is selected, you simply take the control ID, look it up in the array, and call that function.
No snowflake in an avalanche feels responsible.

newAsm

Thanks ToutEnMasm and Tedd,

I have not thought of using a listview, in which case I need to use checkbox with it. Great idea! I will create a separate project for this because it is a branch from the main idea.

I would appreciate Tedd, if you could tell me how I can use one class and give them an ID for all the control. One thing that I did not mention is that I need to know which instruction is been operated upon and the user must start from the 1st to the last. However the actions that need to be taken - check if what they have clicked is correct. The last zip file cannot build. This GUI .exe is attached and works.

How do you check which label has been clicked so that you can change the label informationif all the labels or checkboxes have the same ID?

Great, the pot is stirring with great ideas. Thanks.


[attachment deleted by admin]

Tedd

I said give each control a sequential ID - in other words, the first has ID 1, the next has ID 2, then 3, 4, 5, etc... Not all the same, otherwise, yes, you'd have trouble telling which was clicked (though you could look-up handles.) If you like, you can partition them into ranges (first set are 100s, next 200s, etc) and then check the range to see which group it fits into, and which array to use for lookup.
The exe in the attachment appears to do nothing (no window, just runs and exits.) But I took a quick look through the code. There's no need to store the handles of each control (unless you plan to use them for something else.) And there's also no need for any kind of sub/super-classing.
When a control is clicked, the parent window receives a message indicating that (for a dialog window, the dialog itself is the parent of its controls.) Most of these notifications are sent as WM_COMMANDs, so you can catch them all within the DialogProc that's handling the dialog window. As part of that message, you're told the ID of the control concerned (i.e. which was clicked/selected/changed/etc) and its handle. So you can use the ID to lookup what function must be performed, and the the handle if you need to adjust/update the state of the control.
No snowflake in an avalanche feels responsible.

newAsm

Thanks Tedd for your suggestion. I have already done that. Thanks.