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

📄 alckey.c

📁 在C语言中使用汇编语言设计边框范例  .zip
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************

    PROGRAM:  alckey

    PURPOSE:  Microsoft Sample Application that demonstrates ALC_ flags
              and the ShowKeyboard API for Windows for Pens.
              
              Author:  Cynthia G. Anderson, 
                       PSS Developer Support, Windows SDK Developer Support
              Created: 9/15/92

    FUNCTIONS:

         WinMain() - calls initialization function, processes message loop
         MainWndProc() - processes messages
         About() - processes messages for "About" dialog box
         InitApplication() - initializes window data and registers window
         InitInstance() - saves instance handle and creates main window
         AlcDlgProc() - Dialog procedure for setting ALC options
         SetAlcBits() - sets bits if ALC_BITMAP selected in ALC Dialog
         
****************************************************************************/

// COPYRIGHT:
//
//   (C) Copyright Microsoft Corp. 1993.  All rights reserved.
//
//   You have a royalty-free right to use, modify, reproduce and
//   distribute the Sample Files (and/or any modified version) in
//   any way you find useful, provided that you agree that
//   Microsoft has no warranty obligations or liability for any
//   Sample Application Files which are modified.
//

#include "windows.h"
#include "penwin.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include "alckey.h"


int _pascal WinMain( HANDLE, HANDLE, LPSTR, int );
long _far _pascal MainWndProc( HWND, unsigned, WORD, LONG );
BOOL _far _pascal About( HWND, unsigned, WORD, LONG );
BOOL _far _pascal AlcDlgProc( HWND, unsigned, WORD, LONG );
static BOOL InitApplication( HANDLE );
static BOOL InitInstance( HANDLE, int );
VOID SetAlcBits (LPRC lprc, LPSTR lp);


static HANDLE hInst;
static HWND   hwnd;            /* handle to main window */
static HWND   hWndHedit, hWndBedit;  /* handle to child windows..hedit and bedit */
static HWND   hWndKeyBdButton;  /* handle to pen windows keyboard button*/
static HWND   hWndAlcButton;  /* handle to alc settings button */
static HWND   heditFocusWnd = NULL;  //keeper of the last window to have focus
static HWND   hPenWin;               /* handle to penwin.dll if present */
static HBITMAP  hKBUp, hKBDown;   /* showkeyboard bitmaps handles */


/****************************************************************************

    FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)

    PURPOSE: calls initialization function, processes message loop

****************************************************************************/

int _pascal WinMain(HANDLE hInstance, HANDLE hPrevInstance,
                    LPSTR lpCmdLine,  int nCmdShow)
    {
    MSG msg;

    if (hPrevInstance == 0)
        if (InitApplication(hInstance) == 0)
            return (FALSE);

    if (InitInstance(hInstance, nCmdShow) == 0)
        return (FALSE);

    while (GetMessage(&msg, 0, 0, 0) != 0)
        {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
        }

    return (msg.wParam);
    }


/****************************************************************************

    FUNCTION: InitApplication(HANDLE)

    PURPOSE: Initializes window data and registers window class

****************************************************************************/

static BOOL InitApplication(HANDLE hInstance)
    {
    WNDCLASS  wc;
    char      szMenu[11], szClass[12];

    LoadString (hInstance, ID_MENUSTR, szMenu, sizeof (szMenu));
    LoadString (hInstance, ID_CLASSSTR, szClass, sizeof (szClass));

    wc.style          = 0;
    wc.lpfnWndProc    = (WNDPROC)MainWndProc;
    wc.cbClsExtra     = 0;
    wc.cbWndExtra     = 0;
    wc.hInstance      = hInstance;
    wc.hIcon          = LoadIcon(hInstance, "ALCKEY");
    wc.hCursor        = LoadCursor(0, IDC_ARROW);
    wc.hbrBackground  = (HBRUSH)COLOR_WINDOW+1 ;
    wc.lpszMenuName   = szMenu;
    wc.lpszClassName  = szClass;

    return (RegisterClass(&wc));
    }


/****************************************************************************

    FUNCTION:  InitInstance(HANDLE, int)

    PURPOSE:  Saves instance handle and creates main window

****************************************************************************/

static BOOL InitInstance(HANDLE hInstance, int nCmdShow)
    {
    char szClass[12], szTitle[40];

    LoadString (hInstance, ID_CLASSSTR, szClass, sizeof (szClass));
    LoadString (hInstance, ID_CAPTIONSTR, szTitle, sizeof (szTitle));

    hInst = hInstance;

    hwnd = CreateWindow(
             szClass,
             szTitle,
             WS_OVERLAPPEDWINDOW,
             CW_USEDEFAULT,
             CW_USEDEFAULT,
             CW_USEDEFAULT,
             CW_USEDEFAULT,
             0,
             0,
             hInstance,
             0 );

    if (hwnd == 0 )
        return ( FALSE );

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
    return (TRUE);
    }


/****************************************************************************

    FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)

    PURPOSE:  Processes messages

          
****************************************************************************/

long _far _pascal MainWndProc(HWND hWnd, unsigned message,
                              WORD wParam, LONG lParam)
    {

    FARPROC  lpProcAbout, lpProcAlcDlg;
    char szDlgBox[9], szMsgBoxCap[12], szStatus1[14], szStatus2[14];
    char szAlcDlgBox[10];

    LoadString (hInst, ID_DLGBOX, szDlgBox, sizeof (szDlgBox));
    LoadString (hInst, ID_MSGBOXCAP, szMsgBoxCap, sizeof (szMsgBoxCap));
    LoadString (hInst, ID_STATUS1, szStatus1, sizeof (szStatus1));
    LoadString (hInst, ID_STATUS2, szStatus2, sizeof (szStatus2));
    
    LoadString (hInst, ID_ALCDLGBOX, szAlcDlgBox, sizeof(szAlcDlgBox));
    

    switch ( message )
        {
        case WM_CREATE:
         {
         RECT crect;
         int x,y,cx,cy;
         
         //create keyboard button top,left corner
         x=y=0;
         cx=cy=40;    //make buttons 40 pixels square
         hWndKeyBdButton = CreateWindow(
                            (LPSTR)"button",
                            (LPSTR)"ShowKeyBoard",
                            WS_CHILD|WS_VISIBLE | WS_BORDER|BS_OWNERDRAW,
                            x,
                            y,
                            cx,
                            cy,
                            hWnd, 
                            IDC_KEYBDBUTTON,
                            GetWindowWord(hWnd, GWW_HINSTANCE),
                            (LPSTR)NULL);
         
         //load up the keyboard bitmaps, discard when app closes.
         hPenWin = GetSystemMetrics(SM_PENWINDOWS);

         hKBDown = LoadBitmap(hPenWin, MAKEINTRESOURCE(OBM_SKBBTNDOWN));
         hKBUp = LoadBitmap(hPenWin, MAKEINTRESOURCE(OBM_SKBBTNUP));
         
         //create alc settings button top,left corner next to keyboard button
         x=40; y=0;
         cx=cy=40;
         hWndAlcButton = CreateWindow(
                            (LPSTR)"button",
                            (LPSTR)"ALC",
                            WS_CHILD|WS_VISIBLE | WS_BORDER,
                            x,
                            y,
                            cx,
                            cy,
                            hWnd, 
                            IDC_ALCBUTTON,
                            GetWindowWord(hWnd, GWW_HINSTANCE),
                            (LPSTR)NULL);
               
         // create two edit controls, an hedit and a bedit
         GetClientRect(hWnd, &crect);
         
         x =  (crect.right-crect.left)/8;
         cx = (crect.right-crect.left)*4/8;
         y =  (crect.bottom-crect.top)/8;
         cy = (crect.bottom-crect.top)*2/8;
         
         hWndHedit = CreateWindow(
               (LPSTR)"hedit",
               (LPSTR)NULL,
               WS_CHILD|WS_VISIBLE |ES_MULTILINE|ES_LEFT | ES_AUTOVSCROLL|WS_VSCROLL | WS_BORDER | WS_TABSTOP,
               x,
               y,
               cx,
               cy,
               hWnd, 
               (HMENU)NULL,
               GetWindowWord(hWnd, GWW_HINSTANCE),
               (LPSTR)NULL);
               
         x =  (crect.right-crect.left)/8;
         cx = (crect.right-crect.left)*4/8;
         y =  (crect.bottom-crect.top)*4/8;
         cy = (crect.bottom-crect.top)*2/8;
         
         hWndBedit = CreateWindow(
               (LPSTR)"bedit",
               (LPSTR)NULL,
               WS_CHILD|WS_VISIBLE |ES_MULTILINE|ES_LEFT | ES_AUTOVSCROLL | WS_VSCROLL|WS_BORDER | WS_TABSTOP,
               x,
               y,
               cx,
               cy,
               hWnd, 
               (HMENU)NULL,
               GetWindowWord(hWnd, GWW_HINSTANCE),
               (LPSTR)NULL);
        
         }
         
         //set focus to hedit control as a default
         SetFocus(hWndHedit);
         heditFocusWnd = hWndHedit;
         
         break;
        
        case WM_SETFOCUS:
        SetFocus(heditFocusWnd);
        return 0;
        break;
        
        case WM_COMMAND:
            /* Edit control commands
            */
            if (HIWORD(lParam) == EN_SETFOCUS)
              {
              /* Field focus is being set */
              heditFocusWnd = LOWORD(lParam);
              break;
              }
            
            switch ( wParam )
                {
                case IDM_ABOUT:
                    lpProcAbout = MakeProcInstance( About, hInst );
                    DialogBox(hInst, szDlgBox, hWnd, lpProcAbout);
                    FreeProcInstance( lpProcAbout );
                    break;

                case IDC_ALCBUTTON:
                    lpProcAlcDlg = MakeProcInstance(AlcDlgProc, hInst);
                    DialogBox(hInst,szAlcDlgBox, hWnd, lpProcAlcDlg);
                    FreeProcInstance( lpProcAlcDlg);
                    break;
                    
                case IDC_KEYBDBUTTON:

⌨️ 快捷键说明

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