C++ 什么会导致我的C++;win32应用程序是否要在后台运行?

C++ 什么会导致我的C++;win32应用程序是否要在后台运行?,c++,winapi,background,wm-paint,C++,Winapi,Background,Wm Paint,我已经在这个应用程序上工作了至少3-4个月,就在最近它还没有工作 今天就开始了,因为昨天天气很好,很平稳。 现在它运行了,但窗口不可见(我在任务管理器中检查了进程列表,它正在运行)。我已确保 显示窗口(hwnd、nFunsterStil);不是意外删除的,但它仍然存在 我相信这个问题与WM_PAINT有关,因为当程序停止工作时,我正在处理这个问题 这就是我在编译它并开始不可见时所拥有的: PAINTSTRUCT ps; HDC hdc; case WM_PAINT: {

我已经在这个应用程序上工作了至少3-4个月,就在最近它还没有工作

今天就开始了,因为昨天天气很好,很平稳。 现在它运行了,但窗口不可见(我在任务管理器中检查了进程列表,它正在运行)。我已确保 显示窗口(hwnd、nFunsterStil);不是意外删除的,但它仍然存在

我相信这个问题与WM_PAINT有关,因为当程序停止工作时,我正在处理这个问题

这就是我在编译它并开始不可见时所拥有的:

    PAINTSTRUCT ps;
    HDC hdc;
    case WM_PAINT: {
                    hdc = BeginPaint(hwnd, &ps); 
                    static RECT Background, Background2;
                    SetRect(&Background, 0, 0, 476, 555);
                    SetRect(&Background2, 300, 300, 200, 400);
                    FillRect(hdc, &Background, (HBRUSH) (INT_PTR)CreateSolidBrush(RGB(50,55,50)));
                    FillRect(hdc, &Background2, (HBRUSH) (INT_PTR)CreateSolidBrush(RGB(100,200,100)));
                    EndPaint(hwnd, &ps); 
                   }
现在我试着去掉其中的一些行,把整个块变成一条评论,甚至完全删除它,但是没有任何帮助。我知道我可能把电脑的内存弄乱了。所以我的问题是:出了什么问题,我该如何解决?提前感谢您的帮助

以下是完整的消息开关:

    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
   {
switch (message)                  /* handle the messages */
{ 

       case WM_CTLCOLORSTATIC: {
                               HDC hdcStatic = (HDC) wParam;
                               SetTextColor(hdcStatic, RGB(50,255,50));
                               SetBkColor(hdcStatic, RGB(0,0,0));
                               return (INT_PTR)CreateSolidBrush(RGB(0, 0, 0));
                               }
       case WM_CTLCOLOREDIT: {
                             HDC hdcStatic = (HDC) wParam;
                             SetTextColor(hdcStatic, RGB(50,255,50));
                             SetBkColor(hdcStatic, RGB(0,0,0));
                             return (INT_PTR)CreateSolidBrush(RGB(0, 0, 0));
                             }
    case WM_CREATE:
         {
                   // ------------------MENU-------------------
                   HMENU hMenubar = CreateMenu();
                   HMENU hFile = CreatePopupMenu();
                   HMENU hCPP = CreatePopupMenu();
                   HMENU hHELP = CreatePopupMenu();
                   HMENU hCUSTOMIZE = CreatePopupMenu();

                   HMENU hTHEME = CreatePopupMenu();

                   HMENU hNEW = CreatePopupMenu();

                   AppendMenu(hFile, MF_STRING, ID_HOME, "Ho&me");
                   AppendMenu(hFile, MF_SEPARATOR, 0, 0);

                   AppendMenu(hFile, MF_POPUP, (UINT) hNEW, "N&ew...");
                   AppendMenu(hNEW, MF_STRING, ID_NEW, "Not&e");

                   AppendMenu(hFile, MF_STRING, ID_SAVE, "Sa&ve");
                   AppendMenu(hFile, MF_STRING, ID_SHOWCPP, "Ed&it");
                   AppendMenu(hFile, MF_SEPARATOR, 0, 0);
                   AppendMenu(hFile, MF_STRING, ID_CLOSE, "Cl&ose");

                   AppendMenu(hCPP, MF_STRING, ID_SHOWNOTES, "Li&st all notes");
                   AppendMenu(hCPP, MF_STRING, MENU_COREFILES, "Open 'Notes' fol&der");
                   AppendMenu(hCPP, MF_SEPARATOR, 0, 0);
                   AppendMenu(hCPP, MF_STRING, ID_SAVEFILE, "Sa&ve");
                   AppendMenu(hCPP, MF_STRING, ID_SHOWCPP, "Ed&it");

                   AppendMenu(hHELP, MF_STRING, 0, "Help Fil&es...");
                   AppendMenu(hHELP, MF_STRING, MENU_ABOUT, "Ab&out");
                   AppendMenu(hHELP, MF_SEPARATOR, 0, 0);
                   AppendMenu(hHELP, MF_STRING, 0, "Pro&duct Website");

                   AppendMenu(hCUSTOMIZE, MF_POPUP, (UINT) hTHEME, "Current& Theme");
                   AppendMenu(hTHEME, MF_STRING | MF_CHECKED, 0, "Pr&ompt");
                   AppendMenu(hTHEME, MF_STRING, 0, "No&te Pad");

                   AppendMenu(hMenubar, MF_STRING | MF_POPUP, (UINT) hFile, "Fi&le");
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_STRING | MF_POPUP, (UINT) hCPP, "No&tes");
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_STRING | MF_POPUP, (UINT) hHELP, "He&lp");
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_SEPARATOR, 0, 0);
                   AppendMenu(hMenubar, MF_STRING | MF_POPUP, (UINT) hCUSTOMIZE, "Custom&ise");


                   SetMenu(hwnd, hMenubar);

                   // WINDOW FEATURES!!!

                   TEST[1] = CreateWindow(TEXT("BUTTON"), TEXT("List all notes!"),
                   WS_VISIBLE | WS_CHILD | WS_BORDER,
                   200,375,150,25,
                   hwnd,(HMENU) ID_SHOWNOTES, NULL, NULL);

                   MAIN = CreateWindow(TEXT("edit"), TEXT(""),                       
                   WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_READONLY | SBS_RIGHTALIGN | WS_VSCROLL,
                   10,20,516,350,
                   hwnd,(HMENU) 5001, NULL, NULL);

                   EDIT = CreateWindow(TEXT("edit"), TEXT(""),                       
                   WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT | ES_MULTILINE | SBS_RIGHTALIGN | WS_VSCROLL,
                   10,20,516,350,
                   hwnd,(HMENU) 5001, NULL, NULL);
                   ShowWindow(EDIT, SW_HIDE);

                   NAME=CreateWindow(TEXT("edit"), TEXT("-> Title <-"),
                   WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL,
                   10, 0, 516, 20,
                   hwnd, (HMENU) ID_FILENAME, NULL, NULL);
                   ShowWindow(NAME, SW_HIDE);


                   TEST[2] = CreateWindow(TEXT("BUTTON"), TEXT("-> Home <-"),
                   WS_VISIBLE | WS_CHILD | WS_BORDER,
                   200,375,150,25,
                   hwnd,(HMENU) ID_SHOWHOME, NULL, NULL);
                   ShowWindow(TEST[2], SW_HIDE);
                   SetWindowText(MAIN, DEFTEXT);
         break;
         }
    case WM_COMMAND: {
         // MENU ITEMS!!!
                   //Close
              if( LOWORD(wParam) == ID_CLOSE ) {
                  PostQuitMessage (0);  
                  }
              if(LOWORD(wParam) == MENU_COREFILES) {
                                ShellExecute(NULL, "explore", "Notes", NULL, NULL, SW_SHOW);
                                }
              if(LOWORD(wParam) == MENU_ABOUT) {
                                MessageBox(hwnd, "© 2012 Joseph Meadows. \r\nThis program is essentially a reference guide for whatever you want. It can be used to store school notes, or things completely opposite.", "About:",
                                MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_OK);
                                }
              if(LOWORD(wParam) == ID_SHOWCPP) {
                                if(home==3) {
                                            MessageBox(hwnd, "Error: 9026. Cannot edit Home Page.",  "Invalid Action!", 
                                            MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFBUTTON1 | MB_OK);
                                            }
                                 else if(home==1) {
                                                 MessageBox(hwnd, "Error: 6502 Cannot edit System pages.",  "Invalid Action!", 
                                                 MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFBUTTON1 | MB_OK);
                                                 }
                                else {
                                     ShowWindow(EDIT, SW_SHOW);
                                     ShowWindow(NAME, SW_SHOW);
                                     ShowWindow(MAIN, SW_HIDE);
                                     SetWindowText(StatButts[0],"List all notes!");
                                     mode=2;
                                     }
                                     }
              if(LOWORD(wParam) == ID_SAVE) {
                                char* tittle=SaveFile(hwnd, NAME, EDIT);
                                SetWindowText(MAIN, tittle);
                                ShowWindow(EDIT, SW_HIDE);
                                ShowWindow(NAME, SW_HIDE);
                                ShowWindow(MAIN, SW_SHOW);
                                mode=1;
                                }
              if(LOWORD(wParam) == ID_HOME) {
                                if(mode==2){
                                            int Savebox=MessageBox(hwnd, "Would you like to save this page?",  "Save Page", 
                                            MB_ICONQUESTION | MB_SYSTEMMODAL | MB_DEFBUTTON1 | MB_YESNOCANCEL);
                                            switch(Savebox){
                                                            case IDYES: {
                                                                 ShowWindow(EDIT, SW_HIDE);
                                                                 ShowWindow(NAME, SW_HIDE);
                                                                 ShowWindow(MAIN, SW_SHOW);
                                                                 SetWindowText(StatButts[0],"List all notes!");
                                                                 int len = GetWindowTextLength(EDIT)+1;
                                                                 static char title[1000];
                                                                 GetWindowText(EDIT, title, len);
                                                                 SetWindowText(MAIN, title);
                                                                 mode=1;
                                                                 home=1;
                                                                 break;
                                                                 }
                                                            case IDNO: {
                                                                 ShowWindow(EDIT, SW_HIDE);
                                                                 ShowWindow(NAME, SW_HIDE);
                                                                 ShowWindow(MAIN, SW_SHOW);
                                                                 SetWindowText(StatButts[0],"List all notes!");
                                                                 SetWindowText(MAIN, DEFTEXT);
                                                                 mode=1;
                                                                 home=1;
                                                                 }
                                                            case IDCANCEL: {}
                                            }
                                }     
                                if(mode==1){        
                                            ShowWindow(EDIT, SW_HIDE);
                                            ShowWindow(NAME, SW_HIDE);
                                            ShowWindow(MAIN, SW_SHOW);
                                            SetWindowText(MAIN, DEFTEXT);
                                            SetWindowText(StatButts[0],"List all notes!");
                                }
              }
              if(LOWORD(wParam)==ID_NEW) {
                               if(mode==1) {
                                           ShowWindow(EDIT, SW_SHOW);
                                           ShowWindow(NAME, SW_SHOW); 
                                           ShowWindow(MAIN, SW_HIDE);
                                           SetWindowText(TEST[1],"List all notes!");
                                           SetWindowText(EDIT, "");
                                           mode=2;
                               }
              }
              if(LOWORD(wParam)==ID_SHOWHOME) {      
                                                     if(mode==1) {
                                                                 ShowWindow(MAIN, SW_SHOW);
                                                                 ShowWindow(NAME, SW_HIDE);
                                                                 ShowWindow(EDIT, SW_HIDE);
                                                                 ShowWindow(TEST[1], SW_SHOW);
                                                                 ShowWindow(TEST[2], SW_HIDE);
                                                                 home=1;
                                                                 SetWindowText(MAIN, DEFTEXT);
                                                                 SetWindowText(TEST[1], "List all notes!");
                                                                 }
                                                     if(mode!=1) {                  
                                                                 int Savebox=MessageBox(hwnd, "Would you like to save this page?",  "Save Page?", 
                                                                 MB_ICONQUESTION | MB_SYSTEMMODAL | MB_DEFBUTTON1 | MB_YESNOCANCEL);
                                                                 switch(Savebox){
                                                                                 case IDYES: {
                                                                                      ShowWindow(EDIT, SW_HIDE);
                                                                                      ShowWindow(NAME, SW_HIDE);
                                                                                      ShowWindow(MAIN, SW_SHOW);
                                                                                      ShowWindow(TEST[1], SW_SHOW);
                                                                                      ShowWindow(TEST[2], SW_HIDE);
                                                                                      SetWindowText(TEST[1],"List all notes!");
                                                                                      int len = GetWindowTextLength(EDIT)+1;
                                                                                      static char title[1000];
                                                                                      GetWindowText(EDIT, title, len);
                                                                                      SetWindowText(MAIN, title);
                                                                                      mode=1;
                                                                                      home=1;
                                                                                      break;
                                                                                      }
                                                                                 case IDNO: {
                                                                                      ShowWindow(EDIT, SW_HIDE);
                                                                                      ShowWindow(NAME, SW_HIDE);
                                                                                      ShowWindow(MAIN, SW_SHOW);
                                                                                      ShowWindow(TEST[1], SW_SHOW);
                                                                                      ShowWindow(TEST[2], SW_HIDE);
                                                                                      SetWindowText(TEST[1],"List all notes!");
                                                                                      mode=1;
                                                                                      home=1;
                                                                                      }

                                                                 }
                                                     }
                                               }
              if(LOWORD(wParam)==ID_SHOWNOTES) {
                                              if(mode==1) {
                                                                             std::string umm="";
                                                                             ShowWindow(NAME,SW_SHOW);
                                                                             ShowWindow(MAIN,SW_SHOW);
                                                                             ShowWindow(EDIT,SW_HIDE);
                                                                             ShowWindow(TEST[1], SW_HIDE);
                                                                             ShowWindow(TEST[2], SW_SHOW);
                                                                             SetWindowText(NAME, "-> Title <-");
                                                                             WIN32_FIND_DATA File_Buffer;
                                                                             HANDLE hFind = FindFirstFile(TEXT("Notes/*.NNF"), &File_Buffer);
                                                                             PTSTR Files[8999];
                                                                             int num=0;
                                                                             SetWindowText(MAIN, "");
                                                                             if(hFind != INVALID_HANDLE_VALUE) {
                                                                                      do {
                                                                                         PTSTR FileName = File_Buffer.cFileName;

                                                                                         Files[num] = FileName;
                                                                                         num=num+1;

                                                                                         string kkk(FileName);
                                                                                         stringstream nam(kkk);
                                                                                         string name;
                                                                                         getline(nam, name, '.');
                                                                                         umm = Stringadd(umm, name);
                                                                                         //================================================================================================
                                                                                         } while (FindNextFile(hFind, &File_Buffer));
                                                                             std::stringstream out;
                                                                             out << num;
                                                                             std::string numb=out.str();
                                                                             umm=umm+" \r\n \r\n "+"Number of Notes: "+numb;
                                                                             const char * lol=umm.c_str();
                                                                             SetWindowText(MAIN, lol);
                                                                             FindClose(hFind);
                                                             }
                                                             } 
                                                             if(mode!=1) {                  
                                                                 int Savebox=MessageBox(hwnd, "Would you like to save this page?",  "Save Page", 
                                                                 MB_ICONQUESTION | MB_SYSTEMMODAL | MB_DEFBUTTON1 | MB_YESNOCANCEL);
                                                                 switch(Savebox){
                                                                                 case IDYES: {
                                                                                      ShowWindow(EDIT, SW_HIDE);
                                                                                      ShowWindow(NAME, SW_HIDE);
                                                                                      ShowWindow(MAIN, SW_SHOW);
                                                                                      ShowWindow(TEST[1], SW_SHOW);
                                                                                      ShowWindow(TEST[2], SW_HIDE);
                                                                                      SetWindowText(TEST[1],"List all notes!");
                                                                                      int len = GetWindowTextLength(EDIT)+1;
                                                                                      static char title[1000];
                                                                                      GetWindowText(EDIT, title, len);
                                                                                      SetWindowText(MAIN, title);
                                                                                      mode=1;
                                                                                      home=1;
                                                                                      break;
                                                                                      }
                                                                                 case IDNO: {
                                                                                      ShowWindow(EDIT, SW_HIDE);
                                                                                      ShowWindow(NAME, SW_HIDE);
                                                                                      ShowWindow(MAIN, SW_SHOW);
                                                                                      ShowWindow(TEST[1], SW_SHOW);
                                                                                      ShowWindow(TEST[2], SW_HIDE);
                                                                                      SetWindowText(TEST[1],"List all notes!");
                                                                                      mode=1;
                                                                                      home=1;
                                                                                      }

                                                                 }
                                                     }
                                              }                          
         // BUTTONS!!!
                      //Show CPP
         break;
         }
         case WM_PAINT: {
                          PAINTSTRUCT ps;
                          HDC hdc;
                        hdc = BeginPaint(hwnd, &ps); 
                        static RECT Background;
                        SetRect(&Background, 0, 0, 476, 555);
                        FillRect(hdc, &Background, (HBRUSH) (INT_PTR)CreateSolidBrush(RGB(50,55,50)));
                        EndPaint(hwnd, &ps); 
                        break;
                        }
    case WM_DESTROY:
        PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
    default:                      /* for messages that we don't deal with */
        break;
        return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
   }

看起来您在案例末尾缺少了一个
中断

看起来您在案例末尾缺少了一个
中断

当您填充
WNDCLASS
结构,注册并创建主窗口时,您将调用
ShowWindow(句柄,SW_SHOW/SW_HIDE)大概。确保此呼叫没有显示
SW\u HIDE

考虑到您当前的帖子中没有显示您代码的这一部分,我可能会错,但这将是一个明智的选择

编辑:第55ish行,ShowWindow();将nFunsterStil更改为“SW_SHOW”,看看这是否解决了您的问题


@Joseph

当您填写
WNDCLASS
结构、注册并创建主窗口时,您将调用
ShowWindow(handle,SW\u SHOW/SW\u HIDE)大概。确保此呼叫没有显示
SW\u HIDE

考虑到您当前的帖子中没有显示您代码的这一部分,我可能会错,但这将是一个明智的选择

编辑:第55ish行,ShowWindow();将nFunsterStil更改为“SW_SHOW”,看看这是否解决了您的问题


@Joseph

您应该进行调查以确定问题。然后——寻求解决方案

如果您正在创建一个标准的“重叠”窗口(即带有标题栏、系统菜单和最小/最大/关闭按钮)-以上所有内容都应由系统绘制,只有客户端区域(即窗口内部)在
WM_PAINT
处理中绘制。因此,如果你在屏幕上什么也看不到,那么问题可能出在别处

MSVC中有一个很好的工具,叫做Spy++。使用它查找进程/线程,检查它是否确实创建了窗口,检查窗口样式和位置

您还可以在
WM_PAINT
处理中添加断点。如果你的窗口确实存在并且可见,你就会到达那里

关于代码的一些注意事项:

  • 无错误检查(例如测试
    BeginPaint
    )的检索)。您如何知道您的窗口确实已创建(或至少其类已注册)?至少一些调试时宏(如
    断言
    )会有所帮助
  • 如果您使用
    静态RECT
    有什么原因?(在某些非常特殊的情况下,这可能会节省一些堆栈内存)
  • CreateSolidBrush
    返回一个笔刷句柄,必须通过
    DeleteObject
    释放该句柄。实际上你有一个资源泄漏

  • 您应该进行调查以确定问题。然后——寻求解决方案

    如果您正在创建一个标准的“重叠”窗口(即带有标题栏、系统菜单和最小/最大/关闭按钮)-以上所有内容都应由系统绘制,只有客户端区域(即窗口内部)在
    WM_PAINT
    处理中绘制。因此,如果你在屏幕上什么也看不到,那么问题可能出在别处

    MSVC中有一个很好的工具,叫做Spy++。使用它查找进程/线程,检查它是否确实创建了窗口,检查窗口样式和位置

    您还可以在
    WM_PAINT
    处理中添加断点。如果你的窗口确实存在并且可见,你就会到达那里

    关于代码的一些注意事项:

  • 无错误检查(例如测试
    BeginPaint
    )的检索)。您如何知道您的窗口确实已创建(或至少其类已注册)?至少一些调试时宏(如
    断言
    )会有所帮助
  • 如果您使用
    静态RECT
    有什么原因?(在某些非常特殊的情况下,这可能会节省一些堆栈内存)
  • CreateSolidBrush
    返回一个笔刷句柄,必须通过
    DeleteObject
    释放该句柄。实际上你有一个资源泄漏

  • 哦,我不得不调试窗口的次数从这里随机关闭了。@Joseph Meadows:给我们看一些开关的真实代码,这样我们至少可以看到问题是否存在。@Joseph Meadows:好的,至少我们知道,如果您没有放置
    中断
    窗口,您的窗口将刚刚发布一条退出消息。因此问题不在于WM_PAINT?@Joseph Meadows:WM_PAINT有问题
    ,每当您被要求绘制窗口时,您都会发送一条消息退出应用程序。现在似乎还有其他问题,但代码太多,无法查看。试着缩小范围。哦,我不得不调试窗口的次数从这里随机关闭。@Joseph Meadows:给我们看一些开关的真实代码,这样我们至少可以看到问题是否存在。@Joseph Meadows:嗯,至少我们知道,如果您没有设置
    中断
    窗口,您的窗口将刚刚发布一条退出消息。所以问题不在于WM_PAINT?@Joseph Meadows:WM_PAINT
    有问题,您使用发送消息退出应用程序
        LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
        /*  Make the class name into a global variable  */
        char szClassName[ ] = "WindowsApp";
    
        int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)
    
        {
        HWND hwnd, hwnd2;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
    
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) (INT_PTR)CreateSolidBrush(RGB(0,0,0));
    
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;
    
    
    
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "VirtualNotes",       /* Title Text */
           WS_SYSMENU | WS_MINIMIZEBOX, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           554,                 /* The programs width */
           475,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);
    
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }
    
    /* The program return-