• home
  • forum
  • my
  • kt
  • download
  • Create a Textbox / Edit control and track change event

    Author: 2007-09-06 11:03:15 From:

    #include <windows.h>



    int textbox_id = 156;


    LRESULT WINAPI myProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

    {

    if(message == WM_CLOSE)

    PostQuitMessage(0);



    //check if text in textbox has been changed by user

    if(message==WM_COMMAND && HIWORD(wParam)==EN_CHANGE && LOWORD(wParam)==textbox_id)

    {

    //text in the textbox has been modified

    //do your coding here

    }



    return 0;

    }



    int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

    {

    MSG msg;

    HWND myDialog = CreateWindowEx(

    0,WC_DIALOG,"My Window",WS_OVERLAPPEDWINDOW | WS_VISIBLE,

    400,100,200,200,NULL,NULL,NULL,NULL

    );

    //create the textbox

    CreateWindowEx(

    WS_EX_CLIENTEDGE, //special border style for textbox

    "EDIT","Modify me",WS_VISIBLE | WS_CHILD,

    10,50,170,50,myDialog,(HMENU)textbox_id,NULL,NULL

    );



    SetWindowLong(myDialog, DWL_DLGPROC, (long)myProc);



    while(GetMessage(&msg,NULL,0,0)) {

    TranslateMessage(&msg);

    DispatchMessage(&msg);

    }



    return 0;

    }

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Basics (9)

    New

    Hot