Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 933
  • Last Modified:

Using MoveWindow for a control in a dialog

I've tried to show a rectangle over the selected control in a dialog. But, when I try to move the rectangle using the movewindow() function, the rectangle just disappears. My guess is that I'm not getting the coordinates of the selected control with respect to the dialog containing that control. How can I do it? The rectangle is simply a static control, and I want to show it round the selected text control.
0
motorway
Asked:
motorway
  • 2
1 Solution
 
scervezaCommented:
[QUOTE]The rectangle is simply a static control, and I want to show it round the selected text control.[/QUOTE]

A static control is a type of text control and showing
it around a selected text control will hide that text
control. Are you sure you want to do that?

Anyways, here's how you move controls around in a dialog
box (using standard windows programming).

LRESULT CALLCACK WndProc(HWND handle, UINT msg, WPARAM wparam, LPARAM lparam)
{
 //...

 case(WM_INITDIALOG) :
 {
  // get rect of dialog's client area
  RECT clientRect;
  GetClientRect(handle, &clientRect);

  // get static control (will vary)
  // and get it's rect
  HWND static_control = GetDlgItem(handle, IDRES_STATIC);
  RECT staticRect;
  GetWindowRect(static_control, &staticRect);
  int dx = staticRect.right - staticRect.left;
  int dy = staticRect.bottom - staticRect.top;

  // move static control around
  MoveWindow(static_control, 15, 15, dx, dy, TRUE);

  return TRUE;
 }

 // ...
}
0
 
scervezaCommented:
sorry that window procedure should be declared
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM) lol.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now