Skip to content

Commit

Permalink
Resize editbox controls
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Nov 28, 2018
1 parent 1188b01 commit 25ce148
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/glpi-wince-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,51 @@ static void setupMainPanel(HWND hWnd)
}
}

static void adjustEditControl(int res, LONG width)
{
HWND edittext;
RECT size;

if (dialog == NULL)
return;

edittext = GetDlgItem(dialog, res);
if (edittext)
{
if (GetWindowRect(edittext, &size))
{
#ifdef DEBUG
Debug2("EditText windows size(%d): %dx%d@%d+%d", res, size.right, size.bottom, size.left, size.top);
#endif
// Resize control
SetWindowPos(edittext, dialog, 0, 0, width - 2*size.left, size.bottom - size.top, SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
}
}

}

static void adjustDialogControls(HWND hWnd)
{
RECT size;

if (dialog == NULL)
return;

#ifdef DEBUG
Debug2("Adjusting control sizes...");
#endif

if (GetClientRect(hWnd, &size) && size.right > 10)
{
#ifdef DEBUG
Debug2("Dialog size: %dx%d", size.right, size.bottom);
#endif
adjustEditControl(IDC_EDIT_URL , size.right);
adjustEditControl(IDC_EDIT_LOCAL, size.right);
adjustEditControl(IDC_EDIT_TAG , size.right);
}
}

LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg) {
Expand All @@ -176,6 +221,9 @@ LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
break;
case WM_SHOWWINDOW:
break;
case WM_SIZE:
adjustDialogControls(hWnd);
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
Expand Down

0 comments on commit 25ce148

Please sign in to comment.