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

📄 009.txt

📁 会变语言实现的一些程序
💻 TXT
📖 第 1 页 / 共 5 页
字号:

_ProcWinMain   proc   uses ebx edi esi hWnd,uMsg,wParam,lParam

  local @szBuffer[128]:byte

 

  mov eax,uMsg

;********************************************************************

  .if eax ==  WM_CLOSE

  invoke  DestroyWindow,hWinMain

  invoke  PostQuitMessage,NULL

;********************************************************************

    .elseif eax ==  WM_CREATE

  mov eax,hWnd

  mov hWinMain,eax

invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr szClass,\

    NULL,WS_CHILD or WS_VISIBLE or ES_MULTILINE \

  or ES_WANTRETURN or WS_VSCROLL or\

  ES_AUTOHSCROLL,0,0,0,0,\

  hWnd,ID_EDIT,hInstance,NULL

  mov hWinEdit,eax

  invoke  CreateToolbarEx,hWinMain,WS_VISIBLE or\

  WS_CHILD or TBSTYLE_FLAT or TBSTYLE_TOOLTIPS or\

  CCS_ADJUSTABLE,ID_TOOLBAR,0,HINST_COMMCTRL,\

  IDB_STD_SMALL_COLOR,offset stToolbar,\

  NUM_BUTTONS,0,0,0,0,sizeof TBBUTTON

  Mov hWinToolbar,eax

  Call   _Resize

;********************************************************************

  .elseif eax ==  WM_COMMAND

  mov eax,wParam

  .if ax == IDM_EXIT

  invoke  EndDialog,hWnd,NULL

  .elseif ax != ID_EDIT

  invoke  wsprintf,addr @szBuffer,\

  addr szFormat,wParam

  invoke  MessageBox,hWnd,addr @szBuffer,\

  addr szCaption,\

  MB_OK or MB_ICONINFORMATION

  .endif

;********************************************************************

  .elseif eax ==  WM_SIZE

  call   _Resize

;********************************************************************

; 处理用户定制工具栏消息

;********************************************************************

  .elseif eax ==  WM_NOTIFY

  mov ebx,lParam

;********************************************************************

; 因为印刷宽度,请注意缩进格式!

;********************************************************************

.if [ebx + NMHDR.code] == TTN_NEEDTEXT

      assume  ebx:ptr TOOLTIPTEXT

    mov eax,[ebx].hdr.idFrom

    mov [ebx].lpszText,eax

    push   hInstance

    pop [ebx].hinst

    assume  ebx:nothing

.elseif ([ebx + NMHDR.code] == TBN_QUERYINSERT) || \

    ([ebx + NMHDR.code] == TBN_QUERYDELETE)

    mov eax,TRUE

    ret

.elseif [ebx + NMHDR.code] == TBN_GETBUTTONINFO

    assume  ebx:ptr TBNOTIFY

    mov eax,[ebx].iItem

    .if eax < NUM_BUTTONS

    mov ecx,sizeof TBBUTTON

    mul   ecx

    add eax,offset stToolbar

    invoke  RtlMoveMemory,addr [ebx].tbButton,eax,sizeof TBBUTTON

    invoke  LoadString,hInstance,[ebx].tbButton.idCommand,\

      addr @szBuffer,sizeof @szBuffer

    lea eax,@szBuffer

    mov [ebx].pszText,eax

      invoke  lstrlen,addr @szBuffer

    mov [ebx].cchText,eax

    assume  ebx:nothing

      mov eax,TRUE

      ret

    .endif

.endif

;********************************************************************

      .else

      invoke  DefWindowProc,hWnd,uMsg,wParam,lParam

      ret

      .endif

;********************************************************************

      xor eax,eax

      ret

 

_ProcWinMain   endp

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

_WinMain   proc

      local @stWndClass:WNDCLASSEX

  local @stMsg:MSG

 

  invoke  InitCommonControls

  invoke  GetModuleHandle,NULL

  mov hInstance,eax

      invoke  LoadMenu,hInstance,IDM_MAIN

  mov hMenu,eax

;********************************************************************

; 注册窗口类

;********************************************************************

  invoke  RtlZeroMemory,addr @stWndClass,sizeof @stWndClass

  invoke  LoadIcon,hInstance,ICO_MAIN

  mov @stWndClass.hIcon,eax

  mov @stWndClass.hIconSm,eax

  invoke  LoadCursor,0,IDC_ARROW

  mov @stWndClass.hCursor,eax

  push   hInstance

  pop @stWndClass.hInstance

  mov @stWndClass.cbSize,sizeof WNDCLASSEX

  mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW

  mov @stWndClass.lpfnWndProc,offset _ProcWinMain

  mov @stWndClass.hbrBackground,COLOR_BTNFACE+1

  mov @stWndClass.lpszClassName,offset szClassName

      invoke  RegisterClassEx,addr @stWndClass

 




9.3 使用工具栏(3)



;********************************************************************

; 建立并显示窗口

;********************************************************************

  invoke  CreateWindowEx,NULL,\

  offset szClassName,offset szCaptionMain,\

  WS_OVERLAPPEDWINDOW,\

  CW_USEDEFAULT,CW_USEDEFAULT,700,500,\

  NULL,hMenu,hInstance,NULL

      mov hWinMain,eax

  invoke  ShowWindow,hWinMain,SW_SHOWNORMAL

  invoke  UpdateWindow,hWinMain

;********************************************************************

; 消息循环

;********************************************************************

  .while  TRUE

  invoke  GetMessage,addr @stMsg,NULL,0,0

  .break  .if eax == 0

  invoke  TranslateMessage,addr @stMsg

    invoke  DispatchMessage,addr @stMsg

  .endw

  ret

 

_WinMain   endp

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

start:

  call   _WinMain

  invoke  ExitProcess,NULL

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

  end start

资源脚本文件Toolbar.rc的内容如下:

 

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#include     

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#define ICO_MAIN   1000

#define IDM_MAIN   1000

#define IDM_NEW 1101

#define IDM_OPEN   1102

#define IDM_SAVE   1103   

#define IDM_PAGESETUP 1104

#define IDM_PRINT 1105

#define IDM_EXIT   1106

#define IDM_CUT 1201

#define IDM_COPY   1202

#define IDM_PASTE 1203

#define IDM_FIND   1204

#define IDM_REPLACE 1205

#define IDM_HELP   1301

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

ICO_MAIN   ICON   "Main.ico"

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

IDM_MAIN   menu   discardable

BEGIN

    popup "文件(&F)"

  BEGIN

    menuitem     "新文件(&N)...", IDM_NEW

    menuitem     "打开文件(&O)...", IDM_OPEN

    menuitem     "保存文件(&S)", IDM_SAVE

  menuitem   separator

      menuitem     "页面设置(&A)...", IDM_PAGESETUP

    menuitem     "打印(&P)...", IDM_PRINT

  menuitem   separator

    menuitem     "退出(&X)", IDM_EXIT

  END

    popup "编辑(&E)"

  BEGIN

    menuitem     "剪切(&U)", IDM_CUT

    menuitem     "拷贝(&C)", IDM_COPY

    menuitem     "粘贴(&P)", IDM_PASTE

  menuitem   separator

    menuitem     "查找字符串(&S)...",IDM_FIND

    menuitem     "替换字符串(&R)...",IDM_REPLACE

  END

    popup "帮助(&H)"

  BEGIN

    Menuitem     "帮助(&H)", IDM_HELP

  END

END

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

stringtable discardable

BEGIN

    IDM_NEW "新建文件"

    IDM_OPEN "打开文件"

⌨️ 快捷键说明

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