TestDlg6.7z



Stealth Dialog-CodeProject 참조
origin : http://www.codeproject.com/KB/shell/StealthDialog.aspx?print=true

//sdkdlg.cpp
// Win32 Dialog.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

// Global Variables:
HINSTANCE  hInst; // current instance

// Forward declarations of functions included in this code module:
BOOL    InitInstance(HINSTANCE, int);
BOOL    OnInitDialog(HWND hWnd);


INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);


int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
 MSG msg;
 //HACCEL hAccelTable;

 // Perform application initialization:
 if (!InitInstance (hInstance, nCmdShow)) return FALSE;
 //hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_STEALTHDIALOG);


 // Main message loop:
 while (GetMessage(&msg, NULL, 0, 0))
 {
  if (!TranslateAccelerator(msg.hwnd, NULL, &msg)||
   !IsDialogMessage(msg.hwnd,&msg) )
  {
   TranslateMessage(&msg);
   DispatchMessage(&msg);
  }
 }
 return (int) msg.wParam;
}

// Initialize the window and tray icon
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
 // prepare for XP style controls
 InitCommonControls();

  // store instance handle and create dialog
 hInst = hInstance;
 HWND hWnd = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DLG_DIALOG),
  NULL, (DLGPROC)DlgProc );
 if (!hWnd) return FALSE;

 // call ShowWindow here to make the dialog initially visible
 ShowWindow(hWnd, SW_RESTORE);

 return TRUE;
}

BOOL OnInitDialog(HWND hWnd)
{

 return TRUE;
}


// Message handler for the app
INT_PTR CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 int wmId, wmEvent;

 switch (message)
 {

 case WM_SYSCOMMAND:
  if((wParam & 0xFFF0) == SC_MINIMIZE)
  {
   ShowWindow(hWnd, SW_HIDE);
   return 1;
  }
 
  break;
 case WM_COMMAND:
  wmId    = LOWORD(wParam);
  wmEvent = HIWORD(wParam);

  //switch (wmId)  {  }
  return 1;
 case WM_INITDIALOG:
  return OnInitDialog(hWnd);
 case WM_CLOSE:
  DestroyWindow(hWnd);
  break;
 case WM_DESTROY:
 
  PostQuitMessage(0);
  break;
 }
 return 0;
}


반응형
Posted by codens


반응형