 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
matt Guest
|
Posted: Sat Mar 06, 2004 1:54 am Post subject: Picture Control Not Reseting Right |
|
|
I use the following code in OnInitDialog for a secondary window opened
in the main window by hitting DoModal():
P_Icons[0] = IDI_BACK;
HICON hIcon1 = (HICON)
::LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(P_Icons[0]),IMAGE_ICON,38,41,LR_DEFAULTCOLOR);
m_hole_1.SetIcon(hIcon1);
UpdateData(FALSE);
This works the first time through, and the picture control's icon is
change periodically. However, when the window is destroyed (hitting
the OnOk button), and the window is re-created again from the main
window with DoModal again, the picture control shows the icon that was
last assigned before the window was last deleted, even though every
time this window is created, in its OnInitDialog, I specifically
assign it the same starting icon! How can this code be essentially
ignored in OnInitDialog?
To make things stranger, if I use the following line to load the icon
(instead of the one above), things work:
HICON hIcon1 = (HICON)
::LoadImage(NULL,P_Icons[0],IMAGE_ICON,38,41,LR_LOADFROMFILE);
m_hole_1.SetIcon(hIcon1);
UpdateData(FALSE);
Anyone have a clue what's going on? Is the first parameter in
LoadImage correct?
Thanks,
JM
|
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Sat Mar 06, 2004 2:08 am Post subject: Re: Picture Control Not Reseting Right |
|
|
I'll answer the C++ related parts, the windowing stuff is off-topic here.
* [email]bonmatt10 (AT) cs (DOT) com[/email] (matt) schriebt:
| Quote: | I use the following code in OnInitDialog for a secondary window opened
in the main window by hitting DoModal():
P_Icons[0] = IDI_BACK;
HICON hIcon1 = (HICON)
|
This is a C cast.
Do you know which of the following,
static_cast
const_cast
reinterpret_cast
it corresponds to in this case?
If not then you're in trouble.
As a newbie, never use C casts.
| Quote: | ::LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(P_Icons[0]),IMAGE_ICON,38,41,LR_DEFAULTCOLOR);
|
Here you're using "magic numbers", 38 and 41.
Those will always get you into trouble.
| Quote: | Anyone have a clue what's going on? Is the first parameter in
LoadImage correct?
|
This is a FAQ:
<url: http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9>
By the nature of the question the FAQ isn't and cannot be complete, so
after _studying_ what the FAQ has to say on this question, also look around.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|