My Project
button.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 #include "../stdafx.h"
3 #include "button.h"
4 
6 {
7 
8 }
9 
11 {
12  this->ID = ID;
13 }
14 
15 Button::Button(int X, int Y, int HEIGHT, int WIDTH, WCHAR* TEXT)
16 {
17  this->create(X, Y, HEIGHT, WIDTH, TEXT);
18 }
19 
21 {
22  this->remove();
23 }
24 
25 HWND Button::create(int X, int Y, int HEIGHT, int WIDTH, WCHAR* TEXT)
26 {
27  if (this->bhWnd)
28  {
29  return this->bhWnd;
30  }
31  this->bhWnd = CreateWindowW(TEXT("BUTTON"), TEXT,
32  WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | BS_BITMAP,
33  X, Y, WIDTH, HEIGHT,
34  this->hWnd, (HMENU)this->ID, this->hInst, NULL);
35  return this->bhWnd;
36 }
37 
38 LRESULT Button::setImage(int rID)
39 {
40  HBITMAP hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(rID));
41  return SendMessageW(this->bhWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
42 }
43 
45 {
46  return this->bhWnd;
47 }
48 
50 {
51  DestroyWindow(GetDlgItem(this->hWnd, this->ID));
52  this->bhWnd = NULL;
53 }
static HINSTANCE hInst
Definition: interface.h:61
Button interface class.
~Button()
Definition: button.cpp:20
LRESULT setImage(int rID)
Definition: button.cpp:38
HWND create(int X, int Y, int HEIGHT, int WIDTH, WCHAR *TEXT) override
Definition: button.cpp:25
void remove() override
Definition: button.cpp:49
HWND getHWND()
Definition: button.cpp:44
static HWND hWnd
Definition: interface.h:60
Button()
Definition: button.cpp:5