GetDlgItemInt doesn't work

Aug 23, 2012 at 8:48am
Hello,

I have a dialog and a picture control inside of it. During OnInitDialog I try to obtain the text part of the picture control like this

1
2
3
4
CWnd *dialogHandle; // Handle of the dialog
CWnd *itemHandle; // Handle of the picture control
BOOL error;
dialogHandle->GetDlgItemInt(itemHandle->GetDlgCtrlID(), &error, 0);


however GetDlgItemInt function set error to 0 which says there is an error

here is the resource line

CONTROL 65443, IDC_PICTURE, "Static", SS_BITMAP, 13, 13, 40, 40

I want this number 65443
Aug 23, 2012 at 10:04am
You are not going to get that number like that.

That is the ID of the BITMAP resource that the picture control is showing.

In order to use the GetDlgItemInt funtion on a window control, the window or control has to carry some sort of textbox or caption - because
the GetDlgItemInt function is just a cover for a WM_GETTEXT message.

So GetDlgItemInt can be used on things like editboxes and buttons.


If I find out differently I'll let you know.
Last edited on Aug 23, 2012 at 10:06am
Aug 23, 2012 at 10:42am
thank you,
I exactly want ID of the bitmap and I couldn't find a way to obtain it for days :\
Aug 23, 2012 at 11:50am
You might not be able to do that - but it is maybe possible to get a handle to the bitmap.

What are you trying to achieve anyway?
Aug 23, 2012 at 7:53pm
closed account (DSLq5Di1)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645478

@guestgulkan
Whoops.. you're right, sorry! I should have read the posts more thoroughly.
Last edited on Aug 23, 2012 at 11:36pm
Aug 23, 2012 at 8:01pm
@ sloppy9 - That not the issue here is it??
Aug 23, 2012 at 8:38pm
So you have a static control being used to display a bitmap. Are you wanting the ID of the static control or the ID of the bitmap resource? If the latter are you defining BITMAP resources in the same file something like this?

65443 BITMAP "my_bitmap.bmp"
Topic archived. No new replies allowed.