Thread: My first Windows program

  1. #1
    napKINfolk.com napkin111's Avatar
    Join Date
    Apr 2002
    Posts
    310

    My first Windows program

    Hello, I've just started learning Windows programming and here's my first program. It is very simple...but slightly humorous.

    napKIN
    "The best way to get answers is to just keep working the problem, recognizing when you are stalled, and directing the search pattern.....Don’t just wait for The Right Thing to strike you – try everything you think might even be in the right direction, so you can collect clues about the nature of the problem."
    -John Carmack

  2. #2
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225
    Hello napkin

    Can you post your source codes? I'm into Windows GUI programming and I'm hoping to learn a lot more from studying other's programs.
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    LoL nice program, i had ME before, very unstable, but could i ask you one question?

    How did you get the console window to stay behind the program? This could be very useful in debuging stuff.
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    7

    159632

    question:

    let say i have a Edit Box, a Button and a List Box. i'm going to type a message into the Edit Box and when i hit the Enter(or Return), the message is going to be appeared on the List Box. How can i do that?


    thanatos

  5. #5
    napKINfolk.com napkin111's Avatar
    Join Date
    Apr 2002
    Posts
    310
    Billholm: I'll try to remember to bring in the code and post the code on Monday (I'm at school...)

    Okie: The reason the console stays at the back is because I don't know how to make it go away(yet). If you have VC++6 go to File>New...>then under project select 'Console-application.'

    Thanatos: Sorry but I'm just starting and can't answer that (yet)

    Thanks for the responses!

    napKIN

  6. #6
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    GetWindowText() and a SendMessage() work well for your listbox dillema...tell ya what, you put it in a nice post of your own and I'll answer it for you completely

  7. #7
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    Ok napkin. Monday then
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  8. #8
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225
    Okay napkin. On Monday then
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  9. #9
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Exclamation Oops!

    Sorry about my double post. My browser didn't update and I thought I lost my post.
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  10. #10
    napKINfolk.com napkin111's Avatar
    Join Date
    Apr 2002
    Posts
    310
    Ha, I thought yesterday was Friday! Wishful thinking I guess....Anyways, here's all the stuff minus the debug directory. The .rc (resource script) and resource.h files are required to compile.

    napKIN
    "The best way to get answers is to just keep working the problem, recognizing when you are stalled, and directing the search pattern.....Don’t just wait for The Right Thing to strike you – try everything you think might even be in the right direction, so you can collect clues about the nature of the problem."
    -John Carmack

  11. #11
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post thanatos, you can try this:

    I can't remember exactly how, but you can do this. Give the edit box its own WndProc, and catch the WM_KEYDOWN message. Something like:

    case WM_KEYDOWN:
    switch(LOWORD(wParam))
    {
    case VK_RETURN:
    GetWindowText(hwnd, buffer, 100);

    SendMessage(hListBox, LB_ADDSTRING, (LPARAM) 100, (WPARAM) buffer);
    break;
    }
    break;
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  12. #12
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    To get rid of the console window, instead of going to Win32 Console Application, goto Win32 Application.

    To make the text go in when enter is pressed, you can just make a default button and then the default button will respond to the return.

  13. #13
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    Ok napkin!

    I already downloaded your code. I'm gonna try it at home
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  14. #14
    Registered User
    Join Date
    May 2002
    Posts
    7
    SyntaxBubble:
    i did what you suggested but still not ok.

    part of the codes:
    <code>
    case WM_KEYDOWN:
    switch(LOWORD(wParam))
    {
    case VK_RETURN:
    int len=0;
    char *textbuff;
    len = GetWindowTextLength(GetDlgItem(hwnd,IDC_EDIT1));
    textbuff=(char*)GlobalAlloc(GPTR,len+1);
    GetDlgItemText(hwnd,IDC_EDIT1,textbuff,len+1);
    SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0, (LPARAM)textbuff);
    GlobalFree((HANDLE)textbuff);
    break;
    }
    break;
    <\code>


    please advice.


    thanatos

  15. #15
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96

    Exclamation Thonatos, HTML is off and UBB is on.

    Use UBB instead of HTML code, Thonatos.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  3. Program works on Windows XP and 2000, not on 98 or ME
    By MidnightlyCoder in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 03:36 PM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  5. my first windows console program
    By Syneris in forum Windows Programming
    Replies: 3
    Last Post: 04-08-2002, 03:18 PM