⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mywindow.h

📁 课程设计的目的 本设计的目的是:加深对进程概念及进程管理各部分内容的理解;熟悉FCFS和SPF两种进程调度算法。 课程设计的要求 (1)设计一个完整的进程调度系统
💻 H
字号:
#include <iostream>
//#include <tchar.h>
#include <windows.h>
#include "resource.h"
#define MAX_STR 100

// 全局变量:
HINSTANCE hInst;                                                    // 当前实例
// 此代码模块中包含的函数的前向声明:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE hInstance, int nCmdShow);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);


//
//  函数: MyRegisterClass()
//
//  目的: 注册窗口类。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX); 
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = (WNDPROC)WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
	wcex.hIcon          = LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = "winclass";
    wcex.hIconSm        = LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1));

    return RegisterClassEx(&wcex);
}

//
//   函数: InitInstance(HANDLE, int)
//
//   目的: 保存实例句柄并创建主窗口。
//
HWND hWnd;
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   

   hInst = hInstance; // 将实例句柄存储在全局变量中

   hWnd = CreateWindow("winclass","消息", WS_OVERLAPPEDWINDOW|WS_MINIMIZEBOX,
                       0, 0, 200, 400, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }
   //CreateWindowEx(0, "listbox","", WS_CHILD | WS_VISIBLE, 0,0,200,200,hWnd,NULL,hInstance,NULL);
   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  函数: WndProc(HWND, unsigned, WORD, LONG)
//
//  目的: 处理主窗口的消息。
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message) 
    {
    case WM_CREATE:
       // std::cout << "Hello! I'm a CONSOLE. The WINDOW is my baby." << std::endl;
        break;
    case WM_COMMAND:
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
		
        // set the foreground color to blue
        SetTextColor(hdc, RGB(0,0,255));
        // set the background color to black
        SetBkColor(hdc, RGB(0,0,0));
        // finally set the transparency mode to transparent
        SetBkMode(hdc, OPAQUE);

        // draw some text at (0,0) reflecting number of times
        // wm_paint has been called
		char buffer[50];
        sprintf(buffer,"消息");
        TextOut(hdc, 0,0, buffer, strlen(buffer));
        EndPaint(hWnd,&ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
      //  std::cout << "Goodbye!" << std::endl << std::endl;
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -