• 自动的关闭对话框 MessageBox


    //
    
    #include <stdlib.h>
    #include <stdio.h>
    #include <windows.h>
    
    /********************************/
    // Code By 
    /********************************/
    
    HHOOK hook=NULL;
    int  MSGRET=0;
    int  k=0;
    HWND MSGHWND,TEXTHWND;
    UINT TD;
    
    void CALLBACK TimerProc(
          HWND hwnd, 
          UINT uMsg, 
          UINT idEvent, 
          DWORD dwTime )
    {
     if (k==0)
     {
      k=5;
      SendMessageA(MSGHWND,WM_COMMAND,6,0);
     }else
     {
      k--;
      char title[100]={0};
      sprintf(title,"退出时间还剩: %d 秒",k);
      SetWindowText(TEXTHWND,title);
     }
    }
    
    LRESULT CALLBACK CBTProc(
           int nCode,      // hook code
           WPARAM wParam,  // depends on hook code
           LPARAM lParam   // depends on hook code
           )
    {
     if (nCode==WH_CBT)
     {
      UnhookWindowsHookEx(hook);
            k=5;
            MSGHWND=(HWND)wParam;
            TEXTHWND=GetDlgItem(MSGHWND,65535);
      TD=SetTimer(0,1,1000,(TIMERPROC)TimerProc);
     }
     return 0;
    }
    void main()
    {
     
     hook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTProc,GetModuleHandle(NULL),0);
     MSGRET=MessageBox(NULL,"退出时间还剩: 5 秒","提示信息:",0x40);
     
     //MSGRET 用来确定你单击的是哪个按钮
     MSG msg;
     while (GetMessage(&msg,NULL,NULL,NULL))
     {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
     }
    
    }

  • 相关阅读:
    22、Flyweight 享元模式
    js随机点名器(简单)
    js随机点名器(简单)
    PHP
    PHP
    Laravel框架实现利用监听器进行sql语句记录功能
    Laravel框架实现利用监听器进行sql语句记录功能
    PhpStorm常用的一些快捷键
    PhpStorm常用的一些快捷键
    HTTP状态码汇总
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13318733.html
Copyright © 2020-2023  润新知