Hi! I need some help from you....
I am opening a dialog box with the dialogBox() function and calling this procedure to catch some messages:
BOOL CALLBACK ReceivedVolanteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (!GetDlgItemText(hwndDlg, ID_ITEMNAME,
szItemName, 80))
*szItemName=0;
// Fall through.
case IDCANCEL:
EndDialog(hwndDlg, wParam);
return TRUE;
}
break;
case WM_INITDIALOG:
// Get the owner window and dialog box rectangles.
if ((hwndOwner = GetParent(hwndDlg)) == NULL)
{
hwndOwner = GetDesktopWindow();
}
GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(hwndDlg, &rcDlg);
CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that
// right and bottom values represent the width and
// height, and then offset the owner again to discard
// space taken up by the dialog box.
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining
// space and the owner's original position.
SetWindowPos(hwndDlg,
HWND_TOP,
rcOwner.left + (rc.right / 2),
rcOwner.top + (rc.bottom / 2),
0, 0, // ignores size arguments
SWP_NOSIZE);
char buffer[256];
sprintf(buffer,"Volante %d Inválido. Favor Introduzca un nuevo código:",volantesCounter-1);
SetDlgItemText(hwndDlg,IDC_VOLANTE_NUMBER,buffer);
if (GetDlgCtrlID((HWND) wParam) != ID_ITEMNAME)
{
HWND prueba=GetDlgItem((HWND) wParam, ID_ITEMNAME);
SetFocus(prueba);
((CEdit*)prueba)->SetLimitText(2);
return FALSE;
}
}
return FALSE;
}
I would like to know how can I set the limit text of my CEdit control wich is in the dialog box.It seems that doesn't find the parent window but I don´t know what to do
Thank you for your help!
I am opening a dialog box with the dialogBox() function and calling this procedure to catch some messages:
BOOL CALLBACK ReceivedVolanteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (!GetDlgItemText(hwndDlg, ID_ITEMNAME,
szItemName, 80))
*szItemName=0;
// Fall through.
case IDCANCEL:
EndDialog(hwndDlg, wParam);
return TRUE;
}
break;
case WM_INITDIALOG:
// Get the owner window and dialog box rectangles.
if ((hwndOwner = GetParent(hwndDlg)) == NULL)
{
hwndOwner = GetDesktopWindow();
}
GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(hwndDlg, &rcDlg);
CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that
// right and bottom values represent the width and
// height, and then offset the owner again to discard
// space taken up by the dialog box.
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining
// space and the owner's original position.
SetWindowPos(hwndDlg,
HWND_TOP,
rcOwner.left + (rc.right / 2),
rcOwner.top + (rc.bottom / 2),
0, 0, // ignores size arguments
SWP_NOSIZE);
char buffer[256];
sprintf(buffer,"Volante %d Inválido. Favor Introduzca un nuevo código:",volantesCounter-1);
SetDlgItemText(hwndDlg,IDC_VOLANTE_NUMBER,buffer);
if (GetDlgCtrlID((HWND) wParam) != ID_ITEMNAME)
{
HWND prueba=GetDlgItem((HWND) wParam, ID_ITEMNAME);
SetFocus(prueba);
((CEdit*)prueba)->SetLimitText(2);
return FALSE;
}
}
return FALSE;
}
I would like to know how can I set the limit text of my CEdit control wich is in the dialog box.It seems that doesn't find the parent window but I don´t know what to do
Thank you for your help!