c++界面窗口与按钮设置

1.获取屏幕宽度:

HDC hdc = ::GetDC(HWND(NULL));
int x = ::GetDeviceCaps(hdc, HORZRES);//获得屏幕宽度
2.隐藏任务栏:
ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW, 1);//任务栏隐藏
3.窗口大小和位置:

CDialogEx::SetWindowPos(&wndTopMost, wndx, 0, 205, 61, SWP_SHOWWINDOW);//窗口大小:205*61,位置:x,wndx;y,0
4.系统托盘设置:

NotifyIcon.cbSize = sizeof(NOTIFYICONDATA);
NotifyIcon.hIcon = AfxGetApp()->LoadIcon(IDI_ICONTP);//图标
NotifyIcon.hWnd = m_hWnd;
NotifyIcon.uID = IDI_ICONTP;
lstrcpy(NotifyIcon.szTip, _T("某某软件"));//文字提示
NotifyIcon.uCallbackMessage = WM_SYSTEMTRAY;
NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
Shell_NotifyIcon(NIM_ADD, &NotifyIcon); 
5.按钮大小和位置

CWnd *pWndl;
pWndl = GetDlgItem(IDC_VM1); //获取控件指针
pWndl->MoveWindow(CRect(0, 0, 102, 60)); //左按钮的大小:102*60,位置:x,0;y,0
6.按钮图片设置

HBITMAP hBmp_btn = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP12));
this->SetBitmap(hBmp_btn);
DeleteObject(hBmp_btn);
7.在onpaint中绘制窗口背景图片:
CPaintDC dc(this); // device context for painting
CImage img;
if (!img.IsNull()) img.Destroy();
HRESULT result = img.Load(_T("./image/BC.bmp"));
if (!img.IsNull()) img.Draw(dc.m_hDC, 0, 0);
img.Destroy();











你可能感兴趣的:(c++界面)