473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
Jul 22 '05 #1
1 1610
I'll answer the C++ related parts, the windowing stuff is off-topic here.
* bo*******@cs.com (matt) schriebt:
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.
::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.

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?
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jeff | last post by:
Hiya, Im currently in the process of developing a picture browser, I want it to run off a CD, basically I have 2 questions for the group. The first is how do I get the program to only view the...
3
by: Sandra Setz | last post by:
Hi, Is it possible to assign the Picture property of a picturebox to the Picture property of an image control? I use an invisble picturebox to make some changes to a picture, but I want to...
2
by: Lyn | last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph) with the following code which is based on MS article http://support.microsoft.com/?id=158941: strPathname =...
2
by: Regnab | last post by:
I've got a YES/NO section of a report I'm making. Depending on certain values, I want to circle either YES or NO. I've got the code working so it'll show or hide the circle, but I can't seem to get...
1
by: Jerry S | last post by:
Hi I wonder if someone can help with this, because there's something I'm not understanding right. I've got a List Array of PictureBoxes. If I call PictureBoxListArray.Clear(), and then...
3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
4
by: MLH | last post by:
Setting form's Picture property to another file from within VBA doesn't repaint the form with new bitmap - for instance... Me.Picture = "c:\pics\MyNewPic.jpg" I tried Me.Repaint afterward,...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
9
by: ziamughal | last post by:
sir i have made a picture viewer application and i have a dirlistbox ,filelistbox ,drivelistbox and image list control on it .now when i select the drive where i have pictures and select the folder...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.