Accueil > > > TEXTBOX,BOUTON,TIMER MASM32
TEXTBOX,BOUTON,TIMER MASM32
Information sur la source
Description
Bonjour a tous, ce code permet de voir,comment on peut gerer un evenement, lorsque l'on appuie sur un bouton. En clair, parce que la... Vous saississez du texte, vous pressez le bouton... Et MAGIC, ca fais du bruit, et vous avez un message. Conclusion: Ce code a des fonctions simples a comprendre,comment par exemple,l'utilisation d' un timer. Ce code n'est pas destiné aux experts, mais au simple débutant, qui desire apprendre. Je ne detaillerais rien, car il y a beaucoup de renseignement sur le Web,qui vous permet de trouver votre reponse..Pareil pour les troubles du comportement. :-) http://trans.voila.fr/ <--- un site de traduction,comme par hazard!! Bon Coding!
Source
- .386
- .model flat, stdcall
- option casemap :none
-
- include \masm32\include\windows.inc
- include \masm32\include\user32.inc
- include \masm32\include\kernel32.inc
- includelib \masm32\lib\user32.lib
- includelib \masm32\lib\kernel32.lib
- include \MASM32\INCLUDE\gdi32.inc
- includelib \MASM32\LIB\gdi32.lib
-
- EditSl PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
- PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
-
-
- szText MACRO Name, Text:VARARG
- LOCAL lbl
- jmp lbl
- Name db Text,0
- lbl:
- ENDM
-
-
-
- m2m MACRO M1, M2
- push M2
- pop M1
- ENDM
-
-
- return MACRO arg
- mov eax, arg
- ret
- ENDM
-
- WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
- WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
- TopXY PROTO :DWORD,:DWORD
-
-
-
- .data
- adrTxt db 0
- Moment db 0
- szDisplayName db "Vv@20oX",0
- CommandLine dd 0
- hWnd dd 0
- hInstance dd 0
- btnClass db "BUTTON",0
- hFont dd 0
- hEdit1 dd 0
-
- .DATA?
- Buffer db 256 dup(?)
-
- .code
-
-
- start:
- invoke GetModuleHandle, NULL
- mov hInstance, eax
-
- invoke GetCommandLine
- mov CommandLine, eax
-
- invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
-
- invoke ExitProcess,eax
-
-
-
- WinMain proc hInst :DWORD,
- hPrevInst :DWORD,
- CmdLine :DWORD,
- CmdShow :DWORD
-
-
- LOCAL wc :WNDCLASSEX
- LOCAL msg :MSG
-
- LOCAL Wwd :DWORD
- LOCAL Wht :DWORD
- LOCAL Wtx :DWORD
- LOCAL Wty :DWORD
-
- szText szClassName,"Vv@20o3Class32"
-
-
-
- mov wc.cbSize, sizeof WNDCLASSEX
- mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
- mov wc.lpfnWndProc, offset WndProc ; address of WndProc
- mov wc.cbClsExtra, NULL
- mov wc.cbWndExtra, NULL
- m2m wc.hInstance, hInst ; instance handle
- mov wc.hbrBackground, COLOR_BTNFACE+1 ; system color
- mov wc.lpszMenuName, NULL
- mov wc.lpszClassName, offset szClassName ; window class name
- invoke LoadIcon,hInst,500 ; icon ID ; resource icon
- mov wc.hIcon, eax
- invoke LoadCursor,NULL,IDC_ARROW ; system cursor
- mov wc.hCursor, eax
- mov wc.hIconSm, 0
-
- invoke RegisterClassEx, ADDR wc ; register the window class
-
- mov Wwd, 200
- mov Wht, 150
-
- invoke GetSystemMetrics,SM_CXSCREEN ; get screen width in pixels
- invoke TopXY,Wwd,eax
- mov Wtx, eax
-
- invoke GetSystemMetrics,SM_CYSCREEN ; get screen height in pixels
- invoke TopXY,Wht,eax
- mov Wty, eax
-
-
- invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
- ADDR szClassName,
- ADDR szDisplayName,
- WS_OVERLAPPEDWINDOW,
- Wtx,Wty,Wwd,Wht,
- NULL,NULL,
- hInst,NULL
-
- mov hWnd,eax ; copy return value into handle DWORD
-
-
-
- invoke ShowWindow,hWnd,SW_SHOWNORMAL ; display the window
- invoke UpdateWindow,hWnd ; update the display
-
-
- StartLoop:
- invoke GetMessage,ADDR msg,NULL,0,0 ; get each message
- cmp eax, 0 ; exit if GetMessage()
- je ExitLoop ; returns zero
- invoke TranslateMessage, ADDR msg ; translate it
- invoke DispatchMessage, ADDR msg ; send it to message proc
- jmp StartLoop
- ExitLoop:
-
- return msg.wParam
-
- WinMain endp
-
-
-
- WndProc proc hWin :DWORD,
- uMsg :DWORD,
- wParam :DWORD,
- lParam :DWORD
-
-
- .if uMsg == WM_COMMAND
-
-
- .if wParam == 600
-
- invoke SendMessage,hEdit1,WM_GETTEXT,sizeof Buffer,ADDR Buffer
- invoke MessageBox,hWin,ADDR Buffer,ADDR szDisplayName,0
- Invoke SetTimer,hWin,0,1500, 0
-
- .endif
-
- .elseif uMsg == WM_CREATE
-
-
- szText font1,"Lucida Console"
- invoke CreateFont,13,5,0,0,500,0,0,0, DEFAULT_CHARSET,0,0,0, DEFAULT_PITCH,ADDR font1
- mov hFont, eax
-
-
-
- invoke EditSl,ADDR adrTxt,10,10,170,20,hWin,700
- mov hEdit1, eax
- invoke PushButton,ADDR btnClass,hWin,50,40,80,25,600
-
-
-
-
- .elseif uMsg == WM_CLOSE
-
- szText TheText,"Please Confirm Exit"
- invoke MessageBox,hWin,ADDR TheText,ADDR szDisplayName,MB_YESNO
- .if eax == IDNO
- return 0
- .endif
-
- .elseif uMsg == WM_DESTROY
-
- invoke PostQuitMessage,NULL
- return 0
- .endif
-
- .if uMsg == WM_TIMER
-
-
- .if Moment == 0
- invoke Beep,200,20
- mov Moment,2
- .else
- Mov Moment,0
- invoke Beep,500,30
-
- .endif
-
-
-
- .endif
-
-
- invoke DefWindowProc,hWin,uMsg,wParam,lParam
-
- ret
-
- WndProc endp
-
-
-
- TopXY proc wDim:DWORD, sDim:DWORD
-
-
- shr sDim, 1 ; divide screen dimension by 2
- shr wDim, 1 ; divide window dimension by 2
- mov eax, wDim ; copy window dimension into eax
- sub sDim, eax ; sub half win dimension from half screen dimension
-
- return sDim
-
- TopXY endp
-
-
- EditSl proc szMsg:DWORD,a:DWORD,b:DWORD,
- wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD
-
- LOCAL hndle:DWORD
-
- szText slEdit,"EDIT"
-
- invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR slEdit,szMsg,
- WS_VISIBLE or WS_CHILDWINDOW or ES_AUTOHSCROLL or ES_NOHIDESEL,
- a,b,wd,ht,hParent,ID,hInstance,NULL
-
- mov hndle, eax
-
- invoke SendMessage,hndle,WM_SETFONT,hFont,1
-
- mov eax, hndle
-
- ret
-
- EditSl endp
-
- PushButton proc lpText:DWORD,hParent:DWORD,a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD
- invoke CreateWindowEx,0,
- ADDR btnClass,lpText,
- WS_CHILD or WS_VISIBLE,
- a,b,wd,ht,hParent,ID,
- hInstance,NULL
-
- ret
-
- PushButton endp
- end start
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
include \MASM32\INCLUDE\gdi32.inc
includelib \MASM32\LIB\gdi32.lib
EditSl PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
m2m MACRO M1, M2
push M2
pop M1
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY PROTO :DWORD,:DWORD
.data
adrTxt db 0
Moment db 0
szDisplayName db "Vv@20oX",0
CommandLine dd 0
hWnd dd 0
hInstance dd 0
btnClass db "BUTTON",0
hFont dd 0
hEdit1 dd 0
.DATA?
Buffer db 256 dup(?)
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst :DWORD,
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD
szText szClassName,"Vv@20o3Class32"
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc ; address of WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst ; instance handle
mov wc.hbrBackground, COLOR_BTNFACE+1 ; system color
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName ; window class name
invoke LoadIcon,hInst,500 ; icon ID ; resource icon
mov wc.hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW ; system cursor
mov wc.hCursor, eax
mov wc.hIconSm, 0
invoke RegisterClassEx, ADDR wc ; register the window class
mov Wwd, 200
mov Wht, 150
invoke GetSystemMetrics,SM_CXSCREEN ; get screen width in pixels
invoke TopXY,Wwd,eax
mov Wtx, eax
invoke GetSystemMetrics,SM_CYSCREEN ; get screen height in pixels
invoke TopXY,Wht,eax
mov Wty, eax
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax ; copy return value into handle DWORD
invoke ShowWindow,hWnd,SW_SHOWNORMAL ; display the window
invoke UpdateWindow,hWnd ; update the display
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0 ; get each message
cmp eax, 0 ; exit if GetMessage()
je ExitLoop ; returns zero
invoke TranslateMessage, ADDR msg ; translate it
invoke DispatchMessage, ADDR msg ; send it to message proc
jmp StartLoop
ExitLoop:
return msg.wParam
WinMain endp
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
.if uMsg == WM_COMMAND
.if wParam == 600
invoke SendMessage,hEdit1,WM_GETTEXT,sizeof Buffer,ADDR Buffer
invoke MessageBox,hWin,ADDR Buffer,ADDR szDisplayName,0
Invoke SetTimer,hWin,0,1500, 0
.endif
.elseif uMsg == WM_CREATE
szText font1,"Lucida Console"
invoke CreateFont,13,5,0,0,500,0,0,0, DEFAULT_CHARSET,0,0,0, DEFAULT_PITCH,ADDR font1
mov hFont, eax
invoke EditSl,ADDR adrTxt,10,10,170,20,hWin,700
mov hEdit1, eax
invoke PushButton,ADDR btnClass,hWin,50,40,80,25,600
.elseif uMsg == WM_CLOSE
szText TheText,"Please Confirm Exit"
invoke MessageBox,hWin,ADDR TheText,ADDR szDisplayName,MB_YESNO
.if eax == IDNO
return 0
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif
.if uMsg == WM_TIMER
.if Moment == 0
invoke Beep,200,20
mov Moment,2
.else
Mov Moment,0
invoke Beep,500,30
.endif
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
TopXY proc wDim:DWORD, sDim:DWORD
shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension
return sDim
TopXY endp
EditSl proc szMsg:DWORD,a:DWORD,b:DWORD,
wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD
LOCAL hndle:DWORD
szText slEdit,"EDIT"
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR slEdit,szMsg,
WS_VISIBLE or WS_CHILDWINDOW or ES_AUTOHSCROLL or ES_NOHIDESEL,
a,b,wd,ht,hParent,ID,hInstance,NULL
mov hndle, eax
invoke SendMessage,hndle,WM_SETFONT,hFont,1
mov eax, hndle
ret
EditSl endp
PushButton proc lpText:DWORD,hParent:DWORD,a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD
invoke CreateWindowEx,0,
ADDR btnClass,lpText,
WS_CHILD or WS_VISIBLE,
a,b,wd,ht,hParent,ID,
hInstance,NULL
ret
PushButton endp
end start
Conclusion
C'est beau, c'est neuf et ca brille. Ce programme n'est vraiment pas compliqué. Bon coding,que la patience soient avec vous!
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|