使用WDK編譯環境編譯應用程式build命令(對話方塊程式)

來源:互聯網
上載者:User

TARGETNAME=Dlg
TARGETTYPE=PROGRAM

SOURCES=Dlg.cpp \
        Dlg.rc

UMENTRY=winmain
USE_MSVCRT = 1

UMTYPE=windows
UMLIBS=$(SDK_LIB_PATH)\gdi32.lib    \
       $(SDK_LIB_PATH)\user32.lib   \
       $(SDK_LIB_PATH)\kernel32.lib \

  $(SDK_LIB_PATH)\Ntdll.lib
\

sources檔案內容


!INCLUDE $(NTMAKEENV)\makefile.def

makefile檔案內容




resource.h檔案

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Dlg.rc
//
#define IDD_DIALOG1                     101
#define IDR_MENU                        102
#define ID__CHECK                       40001
#define ID__EXIT                        40002

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif


Dlg.rc檔案內容

--------------------------------------------------------------------------------------------

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include <windows.h>

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG1 DIALOGEX 0, 0, 316, 183
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,205,162,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,259,162,50,14
END

/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 309
        TOPMARGIN, 7
        BOTTOMMARGIN, 176
    END
END
#endif    // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

IDR_MENU MENU
BEGIN
    POPUP ""
    BEGIN
        MENUITEM "Check",                       ID__CHECK
        MENUITEM "Exit",                        ID__EXIT
    END
END

/////////////////////////////////////////////////////////////////////////////

Dlg.cpp源檔案內容:

--------------------------------------------------------------------------------------------------------------------

#include "resource.h"

HINSTANCE g_hInstance;

INT_PTR CALLBACK DialogProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_INITDIALOG:
//MessageBox(hwndDlg, TEXT(""), TEXT(""), MB_OK);
break;
case WM_COMMAND:
{
if(wParam == IDOK)
{
EndDialog(hwndDlg, 0);
}
else if(wParam == IDCANCEL)
{
EndDialog(hwndDlg, 0);
}
}
break;
case WM_CONTEXTMENU:
{
HMENU hmenu;            // menu template          
HMENU hmenuTrackPopup;  // shortcut menu   

//  Load the menu template containing the shortcut menu from the 
//  application's resources. 

hmenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU)); 
if (hmenu == NULL) 
return FALSE; 

// Get the first shortcut menu in the menu template. This is the 
// menu that TrackPopupMenu displays. 

hmenuTrackPopup = GetSubMenu(hmenu, 0); 

// TrackPopup uses screen coordinates, so convert the 
// coordinates of the mouse click to screen coordinates. 
POINT pt;

pt.x = (SHORT)LOWORD(lParam);
pt.y = (SHORT)HIWORD(lParam);

ScreenToClient(hwndDlg, (LPPOINT) &pt); 

// Draw and track the shortcut menu.  
TrackPopupMenu(hmenuTrackPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON, 
pt.x, pt.y, 0, hwndDlg, NULL); 

// Destroy the menu. 
DestroyMenu(hmenu); 

break;
}
break;
}
return 0;
}

int WINAPI WinMain(          
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
g_hInstance = hInstance;
INT_PTR hDlg = DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
return 0;
}

有時間學習學習學習資源檔的文法,將上面的分另儲存為: sources、makefile、resource.h、Dlg.rc、Dlg.cpp放到同一目錄下,開啟WDK編譯環境切換到檔案存放目錄下,輸入命令buid
-c就可以編譯出一個對話方塊程式。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.