Results 1 to 14 of 14

Thread: First Windows app

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Hello,

    Okay i am trying at my first window app and I need some help...

    All I have is a text box and a command button.
    After the user enters in a name like c:\mytext.txt
    and then hits the okay button I would like it to pull up the console and display the text there.

    I know how to call up the system and how to display the file once opened, but I do not know how to tell the okay button to do that.

    Any help would be apprecitated.

    Thanks

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You need to catch the WM_COMMAND message in your window procedure. Are you using dialogue boxes or windows?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    dialog boxes

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Something similar to this, then:
    Code:
    LRESULT __stdcall MainDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    	switch(uMsg) {
    		case WM_COMMAND:
    			switch(LOWORD(wParam)) {
    				case IDC_BTN_GO:
    					MessageBox(hWndDlg, "Hello", "Go!", MB_OK);
    					return TRUE;
    			}
    			break;
    
    	}
    	return FALSE;
    }
    Replace IDC_BTN_GO with the ID of your button. You can then use GetDlgItem to get the window handle of the text box, and retrieve its text using GetDlgItemText
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Im lost.
    Its funny too.
    I have a very good knowledge of C and C++,
    but how come I am lost when it comes to this?

    I think a MVC++ book will

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Because you have to understand how the Windows API works to create windows / dialogue boxes.

    If you read through the introductory parts of the Platform SDK it helps to clear things up a lot. In the meantime I have a couple of example projects that might help for reference value:

    http://www.parksie.net/Raw.zip
    http://www.parksie.net/RawDlg.zip

    PS: if you get any warnings about INT_PTR or LONG_PTR change them to LRESULT
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Okay, im going to dl your files,

    do you think the MVc++ book would be great help?

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I doubt it, because those books usually talk about MFC

    Vlatko's big long list of sites is probably all the reference you'll need. Plus, if you DL the Platform SDK you'll make your life a lot easier -- it's really helped me
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Parksie could you tell me why this create file function doesnt work ?

    Code:
    HCURSOR CTestDlg::OnQueryDragIcon()
    {
    	return (HCURSOR) m_hIcon;
    }
    
    void CTestDlg::OnOK() 
    {
    	
    		char *file="C:\testing.txt";
    
    		CreateFile(file,0,FILE_SHARE_DELETE,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,SECURITY_ANONYMOUS);
    
    
    
    
    
    	CDialog::OnOK();
    }

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    char *file="C:\testing.txt";
    \t is an escape character. All filenames should be forward slashes, or \\.

    I see you're still going ahead with MFC
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    hmm
    Well, what else can I use other than mvc++
    If I use a command line editor or not mfc what and how do i do this.

    I cant go to your *.zip files either because my works firewall blocked it.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Here's the dialogue box one.
    Attached Files Attached Files
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    And windows...
    Attached Files Attached Files
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    MFC is not MSVC++. MFC is the Microsoft Foundation Classes, used for simplifying creation of Windows programs. However, it's no help for learning how to make them.

    MSVC++ is the IDE and compiler.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width