News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Change the text in the field

Started by alex-rudenkiy, March 20, 2016, 07:58:17 PM

Previous topic - Next topic

alex-rudenkiy

Please tell me how to change the text in TEST_EDT to "lol how are you?"?

Asm file :

      .486                      ; create 32 bit code
      .model flat, stdcall      ; 32 bit memory model
      option casemap :none      ; case sensitive

      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\gdi32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\include\Comctl32.inc
      include \masm32\include\comdlg32.inc
      include \masm32\include\shell32.inc
      include \masm32\include\oleaut32.inc
      include \masm32\include\msvcrt.inc
      include \masm32\include\dialogs.inc
      include \masm32\macros\macros.asm
      includelib \masm32\lib\masm32.lib
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\msvcrt.lib
Main   PROTO 
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

TEST_DIALOG = 1000
TEST_EDT = 1003
TEST_BTN = 1001
EXIT_BTN = 1002

.data?
hInstance    Dd ?
icce INITCOMMONCONTROLSEX <>

.data

szTitleName db 'Window Application',0

.code
start:
    mov icce.dwSize, SIZEOF INITCOMMONCONTROLSEX
    mov icce.dwICC, ICC_DATE_CLASSES or ICC_INTERNET_CLASSES or ICC_PAGESCROLLER_CLASS or ICC_COOL_CLASSES

    invoke InitCommonControlsEx, offset icce

    invoke GetModuleHandle, NULL
    mov hInstance, eax

    invoke DialogBoxParam, hInstance, TEST_DIALOG, 0, offset WndProc, 0

    invoke ExitProcess,eax
 
WndProc  proc uses ebx edi esi, hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  switch wmsg
    case WM_INITDIALOG
      invoke SendMessage, hwnd, WM_SETICON, 1, FUNC(LoadIcon, NULL, IDI_ASTERISK)
  invoke MessageBox, hwnd, chr$("Started!"), chr$("Test"), 0
    case WM_COMMAND
      switch wparam
        case TEST_BTN
          invoke MessageBox, hwnd, chr$("Hello, world!"), chr$("Test"), 0
        case EXIT_BTN
          jmp exit_program
      endsw
    case WM_CLOSE
      exit_program:
      invoke EndDialog, hwnd, 0

    endsw

  xor eax,eax
ret
WndProc endp
End start


Resource file :

#define MANIFEST 24
#define TEST_DIALOG 1000
#define TEST_BTN 1001
#define TEST_EDT 1003
#define EXIT_BTN 1002
#define IDR_XPMANIFEST1 1

#include "\masm32\include\resource.h"

TEST_DIALOG DIALOGEX 6,6,134,51
CAPTION "Test Dialog"
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
BEGIN
  CONTROL "change text",TEST_BTN,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,6,18,54,13
  CONTROL "hello",TEST_EDT,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,45,34,54,13
  CONTROL "exit",EXIT_BTN,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,72,18,54,13
END

IDR_XPMANIFEST1 MANIFEST "xpmanifest.xml"

jj2007

How would you do it in C/C++ or VB? What does the MSDN documentation say?

TouEnMasm

      .data
      lolhow db "lol how are you?",0
      .code
      ;in the "case TEST_BTN",for example
      invoke SetDlgItemText,hwnd,TEST_EDT,addr lolhow
Fa is a musical note to play with CL