Pelles C forum

C language => Windows questions => Topic started by: Snowman on March 18, 2015, 01:51:41 PM

Title: Winapi beginner: using controls added to dialog
Post by: Snowman 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?
Title: Re: Winapi beginner: using controls added to dialog
Post by: TimoVJL 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
);
Title: Re: Winapi beginner: using controls added to dialog
Post by: Grincheux on March 18, 2015, 06:10:08 PM
Have a look here (https://msdn.microsoft.com/en-us/library/windows/desktop/bb773169(v=vs.85).aspx)


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
Title: Re: Winapi beginner: using controls added to dialog
Post by: Snowman on March 19, 2015, 10:31:38 AM
Thanks to both.  8)