begin process at 2012 05 24 04:11:58
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

c et asm

 > TEXTBOX,BOUTON,TIMER MASM32

TEXTBOX,BOUTON,TIMER MASM32


 Information sur la source

Note :
9 / 10 - par 1 personne
9,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :c et asm Niveau :Débutant Date de création :04/02/2004 Vu :4 670

Auteur : Vv20oX

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 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

CHEMIN DES REPERTOIRES SYSTEM,WINDOWS,TEMPORAIRE,COURANT [MA...
LISTER VOS FICHIER TEMPORAIRE DANS UNE LISTBOX MASM32
COSINUS D'UN ANGLE EN DEGRÉS MASM32
AFFICHER UNE CHAINE DE CARACTERE MASM32
GENERE UN NOM AU HAZARD

 Sources de la même categorie

INTERFACE C ET ASM par parki
Source avec Zip Source avec une capture FONCTION INTTOBIN par Ken21
Source avec Zip MOT PALINDROME par Tinsalhi
EXECUTE /USR/BIN/ID par 0x0syscall
BIBLIOTHEQUE POUR LE 8086 par flory_

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 3,650 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales