ChimpFace9000
Feb 15th, 2001, 02:16 PM
What do i have to do to my code to make the focus change controls when you press tab? Here's my code...
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
include \masm32\include\mac.inc
MainFunction proto
.data
MainWindowClass db "MainWindowClass", 0
StaticClass db "STATIC", 0
ButtonClass db "BUTTON", 0
MainWindowName db "Practice001.exe", 0
StaticOneName db "The colors is...", 0
ButtonOneName db "Red", 0
ButtonTwoName db "Green", 0
.data?
hAppInstance HINSTANCE ?
hMainWindow HWND ?
hStaticOne HWND ?
Colors COLORREF ?
BkColors COLORREF ?
.const
StaticOne equ 0
ButtonOne equ 1
ButtonTwo equ 2
.code
start:
invoke GetModuleHandle, NULL
mov hAppInstance, eax
invoke MainFunction
invoke ExitProcess, 0
MainFunction proc
local WndClassEx:WNDCLASSEX
local Msg:MSG
mov WndClassEx.cbSize, SIZEOF(WNDCLASSEX)
mov WndClassEx.style, CS_DBLCLKS
mov WndClassEx.lpfnWndProc, offset MainWindowProc
mov WndClassEx.cbClsExtra, NULL
mov WndClassEx.cbWndExtra, NULL
push hAppInstance
pop WndClassEx.hInstance
invoke LoadIcon, NULL, IDI_APPLICATION
mov WndClassEx.hIcon, eax
mov WndClassEx.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov WndClassEx.hCursor, eax
mov WndClassEx.hbrBackground, COLOR_WINDOW
mov WndClassEx.lpszMenuName, NULL
mov WndClassEx.lpszClassName, offset MainWindowClass
invoke RegisterClassEx, addr WndClassEx
invoke CreateWindowEx, NULL, addr MainWindowClass, addr MainWindowName, WS_OVERLAPPEDWINDOW, 200, 200, 300, 300, NULL, NULL, hAppInstance, NULL
mov hMainWindow, eax
invoke ShowWindow, hMainWindow, SW_SHOWDEFAULT
invoke UpdateWindow, hMainWindow
.while TRUE
invoke GetMessage, addr Msg, NULL, 0, 0
.BREAK .IF (!eax)
invoke TranslateMessage, addr Msg
invoke DispatchMessage, addr Msg
.endw
ret
MainFunction endp
MainWindowProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg == WM_DESTROY
invoke PostQuitMessage, 0
.elseif uMsg == WM_CLOSE
invoke DestroyWindow, hWnd
.elseif uMsg == WM_CREATE
mov Colors, 000000h
mov BkColors, 0c0c0c0h
invoke CreateWindowEx, NULL, addr StaticClass, addr StaticOneName, WS_CHILD or WS_VISIBLE, 0, 0, 100, 20, hWnd, StaticOne, hAppInstance, 0
mov hStaticOne, eax
invoke CreateWindowEx, NULL, addr ButtonClass, addr ButtonOneName, WS_CHILD or WS_VISIBLE, 0, 21, 60, 35, hWnd, ButtonOne, hAppInstance, 0
invoke CreateWindowEx, NULL, addr ButtonClass, addr ButtonTwoName, WS_CHILD or WS_VISIBLE, 63, 21, 93, 35, hWnd, ButtonTwo, hAppInstance, 0
.elseif uMsg == WM_COMMAND
LOWORD wParam
.if eax == ButtonOne
mov Colors, 0000ffh
invoke InvalidateRect, hStaticOne, NULL, TRUE
.elseif eax == ButtonTwo
mov Colors, 000ff00h
invoke InvalidateRect, hStaticOne, NULL, TRUE
.endif
.elseif uMsg == WM_CTLCOLORSTATIC
invoke GetDlgCtrlID, lParam
.if eax == StaticOne
invoke SetBkColor, wParam, BkColors
invoke SetTextColor, wParam, Colors
invoke CreateSolidBrush, BkColors
ret
.endif
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
.endif
ret
MainWindowProc endp
end start
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
include \masm32\include\mac.inc
MainFunction proto
.data
MainWindowClass db "MainWindowClass", 0
StaticClass db "STATIC", 0
ButtonClass db "BUTTON", 0
MainWindowName db "Practice001.exe", 0
StaticOneName db "The colors is...", 0
ButtonOneName db "Red", 0
ButtonTwoName db "Green", 0
.data?
hAppInstance HINSTANCE ?
hMainWindow HWND ?
hStaticOne HWND ?
Colors COLORREF ?
BkColors COLORREF ?
.const
StaticOne equ 0
ButtonOne equ 1
ButtonTwo equ 2
.code
start:
invoke GetModuleHandle, NULL
mov hAppInstance, eax
invoke MainFunction
invoke ExitProcess, 0
MainFunction proc
local WndClassEx:WNDCLASSEX
local Msg:MSG
mov WndClassEx.cbSize, SIZEOF(WNDCLASSEX)
mov WndClassEx.style, CS_DBLCLKS
mov WndClassEx.lpfnWndProc, offset MainWindowProc
mov WndClassEx.cbClsExtra, NULL
mov WndClassEx.cbWndExtra, NULL
push hAppInstance
pop WndClassEx.hInstance
invoke LoadIcon, NULL, IDI_APPLICATION
mov WndClassEx.hIcon, eax
mov WndClassEx.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov WndClassEx.hCursor, eax
mov WndClassEx.hbrBackground, COLOR_WINDOW
mov WndClassEx.lpszMenuName, NULL
mov WndClassEx.lpszClassName, offset MainWindowClass
invoke RegisterClassEx, addr WndClassEx
invoke CreateWindowEx, NULL, addr MainWindowClass, addr MainWindowName, WS_OVERLAPPEDWINDOW, 200, 200, 300, 300, NULL, NULL, hAppInstance, NULL
mov hMainWindow, eax
invoke ShowWindow, hMainWindow, SW_SHOWDEFAULT
invoke UpdateWindow, hMainWindow
.while TRUE
invoke GetMessage, addr Msg, NULL, 0, 0
.BREAK .IF (!eax)
invoke TranslateMessage, addr Msg
invoke DispatchMessage, addr Msg
.endw
ret
MainFunction endp
MainWindowProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg == WM_DESTROY
invoke PostQuitMessage, 0
.elseif uMsg == WM_CLOSE
invoke DestroyWindow, hWnd
.elseif uMsg == WM_CREATE
mov Colors, 000000h
mov BkColors, 0c0c0c0h
invoke CreateWindowEx, NULL, addr StaticClass, addr StaticOneName, WS_CHILD or WS_VISIBLE, 0, 0, 100, 20, hWnd, StaticOne, hAppInstance, 0
mov hStaticOne, eax
invoke CreateWindowEx, NULL, addr ButtonClass, addr ButtonOneName, WS_CHILD or WS_VISIBLE, 0, 21, 60, 35, hWnd, ButtonOne, hAppInstance, 0
invoke CreateWindowEx, NULL, addr ButtonClass, addr ButtonTwoName, WS_CHILD or WS_VISIBLE, 63, 21, 93, 35, hWnd, ButtonTwo, hAppInstance, 0
.elseif uMsg == WM_COMMAND
LOWORD wParam
.if eax == ButtonOne
mov Colors, 0000ffh
invoke InvalidateRect, hStaticOne, NULL, TRUE
.elseif eax == ButtonTwo
mov Colors, 000ff00h
invoke InvalidateRect, hStaticOne, NULL, TRUE
.endif
.elseif uMsg == WM_CTLCOLORSTATIC
invoke GetDlgCtrlID, lParam
.if eax == StaticOne
invoke SetBkColor, wParam, BkColors
invoke SetTextColor, wParam, Colors
invoke CreateSolidBrush, BkColors
ret
.endif
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
.endif
ret
MainWindowProc endp
end start