Thread: Reusing dialog procedure and resource file code

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595

    Reusing dialog procedure and resource file code

    I've been working on a program that uses a resource file to
    produce a dialog box that has 17 edit boxes for user input
    regarding members of a class and several buttons to control
    doing things with the information like save, cancel, exit.
    I want to use the same information with several different views.
    In one view I want to be able to add the object created to a
    vector. In another view I want to be ablet to view the
    information regarding a given element of the vector in read
    only format, so user can't change the information, just view it.
    In a third view I wantto be able to edit the information of a
    given element of thevector, but not add it anew to the vector.
    I can do all that by using the resource editor to create three
    distinct dialog boxes, one for each view. However, since the
    17 edit boxes and 17 static labels will all be the same I was
    hoping there was a way to change what gets done when a button
    is pushed or to change the baseline behaviour of the edit boxes
    without recreating the entire dialog box for each view.
    I know I can enable/disable and show/noshow buttons on the fly,
    but can I change what gets done when I push the button from one
    view to the other using the same dialog procedure function? Can
    I change baseline behavior of edit boxes between read only and
    editable on the fly? Can I make the entire dialog box read only
    or do I have to change the property of each edit box individually?

    I'm using VC6++ and Windows API.

    Thanks in advance.
    You're only born perfect.

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    EnableWindow?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    can I change what gets done when I push the button from one view to the other using the same dialog procedure function?
    Re-using the dialog and associated controls is certainly possible - all you need is a way of differentiating between the various instances of dialog that is in current use. Any variable with suitable scope would do in this regard so it would simply be a matter of checking(or updating) which dialog (variable value) was active and then forwarding any control events to the appropriate handlers for that scenario.
    Can I change baseline behavior of edit boxes between read only and editable on the fly? Can I make the entire dialog box read only or do I have to change the property of each edit box individually?
    You can change the read-only style bit(EM_SETREADONLY) of the edit controls by sending each a EM_SETREADONLY message; enumerating the dialog's controls (EnumChildWindows) would be a convenient way of doing this for all necessary controls.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Hmmmm

    ^Thinks out loud^

    So to keep track of which "version" of the dialog box I'm using I could either create a global variable or else tuck an additional member variable in the struct I pass by reference to DialogBox() as the 5th argument which will then be available in the dialog procedure as lparam. Hey, I think I can see how that might work, if I can keep all the twists and turns straight. Great!

    Thanks to you both.

    Happy holidays!
    You're only born perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Need help in resource file
    By Darkinyuasha1 in forum Windows Programming
    Replies: 7
    Last Post: 11-27-2006, 07:31 PM
  3. Need an interface written
    By Thantos in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 11-23-2005, 11:19 PM
  4. Resource File Help
    By gcn_zelda in forum Windows Programming
    Replies: 1
    Last Post: 06-07-2003, 08:36 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM