Jump to content

Need some help in Win32 programming

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts
So i have a textbox :
        hwndEdit = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
                50, 50, 150, 20, hwnd, (HMENU) ID_EDIT,
                NULL, NULL);

And i have a button

        hwndButton = CreateWindow( TEXT("button"), TEXT("Color it !"),
            WS_VISIBLE | WS_CHILD,
            50,100,200,25,
            hwnd, (HMENU) ID_BUTTON, NULL, NULL);

and another texbox :)

       CreateWindow(TEXT("Edit"), NULL, WS_CHILD |  WS_VISIBLE | WS_BORDER,
                50, 150, 150, 20, hwnd, (HMENU) ID_EDIT,
                NULL, NULL);


Now i'm not familiar with Win32 codes but what i want to do is
:
1-Get the text from the first texbox on the button click and put it in a string
2-output string results in the second texbox.

So any heads up what functions i should use ?

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Here's a tutorial series. You're going to want to look at the message loop bit. There's a menu on the left side with all the parts.
sudo rm -rf /

#3
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts
I understand Message loops, i just need the function that fetches text from Texboxs D:
GetDlgItem() perhaps ? i can't get it to work

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Got this off of a website:

Quote

Getting Text from the Edit Box

The GetDlgItemText message can be used to retrieve text from the edit control:


GetDlgItemText(hwnd, nEditID, szString, nMax)


The szString parameter is an LPSTR, and nMax indicates the maximum number of characters that we can cope with. If the programmer needs to allocate memory dynamically for this, then a WM_GETTEXTLENGTH message can be sent to the control:

SendMessage( GetDlgItem( hwnd, nEditID), WM_GETTEXTLENGTH, 0, 0L)



The return value from this is the number of characters in the text control.


Using the Win32 API Edit Control



Edited by dargueta, 13 March 2010 - 02:06 PM.
Fixed link

sudo rm -rf /

#5
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts
Awesum thank you !

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
No problem. Glad I could be of help. :)
sudo rm -rf /