如何设置窗口的默认位置?

时间:2012-01-02 23:00:38

标签: c++ windows position

我正在使用Dev C ++。在我创建了一个Windows应用程序之后,它生成了一些创建窗口的代码。我广泛理解代码。我找到了设置大小,标题和背景颜色的代码,但是如何设置新窗口的默认位置?我想在屏幕中央开始它。

1 个答案:

答案 0 :(得分:2)

你应该有CreateWindow函数,它的定义如下:

HWND WINAPI CreateWindow(
  __in_opt  LPCTSTR lpClassName,
  __in_opt  LPCTSTR lpWindowName,
  __in      DWORD dwStyle,
  __in      int x,
  __in      int y,
  __in      int nWidth,
  __in      int nHeight,
  __in_opt  HWND hWndParent,
  __in_opt  HMENU hMenu,
  __in_opt  HINSTANCE hInstance,
  __in_opt  LPVOID lpParam
);

xy参数指定新创建的窗口的位置。这些是你需要设置的。

相关问题