AfxSetResourceHandle() - I failed to load the default resources of the application.
-
In case that some of the buttons' captions (or other resources)of a dialog application have been changed - is it possible at runtime to set all the resources to their original names/values? I tried with AfxSetResourceHandle(), but nothing happened. Any suggestions how to do this? Thanks.
-
In case that some of the buttons' captions (or other resources)of a dialog application have been changed - is it possible at runtime to set all the resources to their original names/values? I tried with AfxSetResourceHandle(), but nothing happened. Any suggestions how to do this? Thanks.
I assume you used a dialog template to create your dialog ? Now, mostly all (if not all) controls you place on this template are NOT resources, but control windows. The button is not a resource; it is a window with "Button" class and a title it displays on it as it's caption. If you use an icon or a bitmapped button, then those resources are bound to the button: a window with a bound resource that is drawn to it. So, once more: the dialog template is a resource, but the controls placed there are not. The template just specifies what controls are placed and where. The Framework will worry about creating these controls and placing them. Consider the template like a drawing plan. If the captions of buttons have changed, it is possible to change them back by using
GetDlgItem
and specifying the ID as parameter. If you convert the return value toCButton*
, you can use the 'SetWindowText' method of the class to set the button's caption. Hope this helps. If it doesn't, I suggest you dig up the infamous 'Programming Windows' book by Charles Petzold. This should help you get started by first introducing you to the concept of resources: what and where they are and how they are used in a Windows environment. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible. -
I assume you used a dialog template to create your dialog ? Now, mostly all (if not all) controls you place on this template are NOT resources, but control windows. The button is not a resource; it is a window with "Button" class and a title it displays on it as it's caption. If you use an icon or a bitmapped button, then those resources are bound to the button: a window with a bound resource that is drawn to it. So, once more: the dialog template is a resource, but the controls placed there are not. The template just specifies what controls are placed and where. The Framework will worry about creating these controls and placing them. Consider the template like a drawing plan. If the captions of buttons have changed, it is possible to change them back by using
GetDlgItem
and specifying the ID as parameter. If you convert the return value toCButton*
, you can use the 'SetWindowText' method of the class to set the button's caption. Hope this helps. If it doesn't, I suggest you dig up the infamous 'Programming Windows' book by Charles Petzold. This should help you get started by first introducing you to the concept of resources: what and where they are and how they are used in a Windows environment. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.OK, thanks! But I was trying to avoid using GetDlgItem and SetWindowText functions. What I was asking was is it possible to load the default values (caption, size and so on)as they are defined in the *.rc file? Let's say the captions of some button or static controls have been changed (using 'SetWindowText'). Is it possible at runtime to restore the original values as they are defined in the *.rc-file? I mean to load them directly from this file? I can't get Petzold's book and that's why I'm asking here. By the way, is it available somewhere on the net as eBook? Greetings -J.