NO

Author Topic: Winapi beginner: using controls added to dialog  (Read 3752 times)

Snowman

  • Guest
Winapi beginner: using controls added to dialog
« on: March 18, 2015, 01:51:41 PM »
Hello everybody, I am a beginner in Windows programming.
I used the Wizard for "simple dialog based application" and it created a program with a dialog that has an OK button.

My problem is that I do not understand how to use controls that I add to the dialog.
For example, if I add a progress bar to the dialog, then how do I access it from WM_INITDIALOG to fill it to 50%?

Normally I should use SendMessage() to the progress bar's handle, but what is the handle?
In other words: how to get the handles for the controls added to the dialog, or is there another way to do things?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Winapi beginner: using controls added to dialog
« Reply #1 on: March 18, 2015, 03:55:55 PM »
Code: [Select]
HWND GetDlgItem(
  HWND hDlg,       // handle to dialog box
  int nIDDlgItem   // control identifier
);
Code: [Select]
LRESULT SendDlgItemMessage(
  HWND hDlg,      // handle to dialog box
  int nIDDlgItem, // control identifier
  UINT Msg,       // message to send
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);
May the source be with you

Grincheux

  • Guest
Re: Winapi beginner: using controls added to dialog
« Reply #2 on: March 18, 2015, 06:10:08 PM »
Have a look here


BOOL WINAPI SetDlgItemText(HWND hDlg,int nIDDlgItem,LPCTSTR lpString);
UINT WINAPI GetDlgItemInt(HWND hDlg,int nIDDlgItem,BOOL *lpTranslated,BOOL bSigned);
int WINAPI GetDlgCtrlID(HWND hwndCtl);
BOOL WINAPI SetDlgItemInt(HWND hDlg,int nIDDlgItem,UINT uValue,BOOL bSigned);


Useful too
« Last Edit: March 18, 2015, 06:14:07 PM by Grincheux »

Snowman

  • Guest
Re: Winapi beginner: using controls added to dialog
« Reply #3 on: March 19, 2015, 10:31:38 AM »
Thanks to both.  8)