Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ISOLATION_AWARE_ENABLED 1
- #include "stdafx.h"
- #include "Process.h"
- #include <iostream>
- #include <memory>
- #include <string>
- #include <vector>
- #include <tchar.h>
- #include "Windows.h"
- #include "commctrl.h"
- #include "resource.h"
- static HINSTANCE mainInstance;
- int MyButtonId = 1000;
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
- {
- mainInstance = hModule;
- WNDCLASSEX wc = { 0 };
- HWND MainHwnd;
- MSG Msg;
- wc.cbSize = sizeof(wc);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = WindowProc;
- wc.hInstance = mainInstance;
- wc.hbrBackground = (HBRUSH)(CreateSolidBrush(RGB(30, 30, 30)));
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "Application";
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- if (!RegisterClassEx(&wc))
- {
- MessageBox(NULL, std::to_string(GetLastError()).c_str(), "RegisterClassEx!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
- MainHwnd = CreateWindowEx(
- WS_EX_CLIENTEDGE,
- "Application",
- "My Application",
- WS_SYSMENU | WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 400, 280,
- NULL, NULL, mainInstance, NULL);
- if (MainHwnd == NULL)
- {
- MessageBox(NULL, std::to_string(GetLastError()).c_str(), "CreateWindow!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
- ShowWindow(MainHwnd, 1);
- UpdateWindow(MainHwnd);
- while (GetMessage(&Msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- return TRUE;
- }
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CREATE: {
- MyButton = CreateWindow("BUTTON", "A Button Text", WS_VISIBLE | WS_CHILD | BS_BITMAP | BS_FLAT, 17, 18, 110, 30, hwnd, (HMENU)PickButtonId, mainInstance, NULL);
- ///////// --->
- // Here I'm using one of these :
- // Using LoadImage()
- MyImage = (HBITMAP)LoadImage(hInstance, "UI\\myimage.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_LOADFROMFILE);
- // Using LoadBitmap() | My_Bitmap is an image resource name
- MyImage = LoadBitmap(hInstance, MAKEINTRESOURCE(My_Bitmap));
- ///////// <---
- SendMessage(MyButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)MyImage);
- break;
- }
- default:
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement