Jump to content

Simple GUI Code

- - - - -

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

#1
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
Hello All,

I was making a GUI while following the tutorial in the YouTube Channel, and I debugged it and the Calculate button doesn't work!:confused:

I'd like to know how to program the button so it works. I mainly use Win32 Applications and started GUI when I saw the tutorial.

Kinda funny lol

Edited by Hunter100, 12 March 2010 - 08:44 PM.


#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Can you post your code?
sudo rm -rf /

#3
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
Just the private sub for the button or the whole thing?

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Um...what you think is pertinent.
sudo rm -rf /

#5
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
[SIZE=2][FONT=Courier New][COLOR=#008000]// [/COLOR][/FONT][/SIZE]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// btnCalculate[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// [/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->Location = System::Drawing::Point([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a]64[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a]72[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->Name = L[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a31515][FONT=Courier New][SIZE=2][COLOR=#a31515][FONT=Courier New][SIZE=2][COLOR=#a31515]"btnCalculate"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->Size = System::Drawing::Size([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a]125[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a]20[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->TabIndex = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a][FONT=Courier New][SIZE=2][COLOR=#a52a2a]5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->Text = L[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a31515][FONT=Courier New][SIZE=2][COLOR=#a31515][FONT=Courier New][SIZE=2][COLOR=#a31515]"Calculate"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->UseVisualStyleBackColor = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]->btnCalculate->Click += [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]gcnew[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] System::EventHandler([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], &Form1::btnCalculate_Click);[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// [/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

I may of made a mistake. But here it is ( I think it is anyway-I'm new to GUI's).

Edited by Hunter100, 13 March 2010 - 04:44 PM.
Clarity


#6
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
If that isn't it don't worry about it. :)

#7
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Huh?
sudo rm -rf /

#8
theonejb

theonejb

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
uh, that is the code that Visual Studio writes for you. What you need to most here is the code for the actual
Form1::btnCalculate_Click

function.


#9
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts
First you need to define the button

#define ID_BUTTON 1

then create it
        hwndButton = CreateWindow( TEXT("button"), TEXT("Button example"),
            WS_VISIBLE | WS_CHILD,
            10,140,465,25,
            hwnd, (HMENU) ID_BUTTON, NULL, NULL);
if button clicks
case WM_COMMAND:
        if(HIWORD(wParam) == BN_CLICKED){
//do stuff;
}


#10
theonejb

theonejb

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts

Moudi said:

First you need to define the button

#define ID_BUTTON 1

then create it

        hwndButton = CreateWindow( TEXT("button"), TEXT("Button example"),
            WS_VISIBLE | WS_CHILD,
            10,140,465,25,
            hwnd, (HMENU) ID_BUTTON, NULL, NULL);
if button clicks
case WM_COMMAND:
        if(HIWORD(wParam) == BN_CLICKED){
//do stuff;
}

I think that code would be used with MFC and Win32 Lib. The code he has posted is probably from C++ .NET, in which case, I don't think your code would work. However, I may be wrong as I haven't used Windows in quite a long time...

#11
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts

theonejb said:

I think that code would be used with MFC and Win32 Lib. The code he has posted is probably from C++ .NET, in which case, I don't think your code would work. However, I may be wrong as I haven't used Windows in quite a long time...
Correct. I haven't used C++.NET because I'm a more sadistic low-level kind of guy, so I'm of little help here. Sorry.
sudo rm -rf /

#12
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts

theonejb said:

I think that code would be used with MFC and Win32 Lib. The code he has posted is probably from C++ .NET, in which case, I don't think your code would work. However, I may be wrong as I haven't used Windows in quite a long time...
Oh yea well i'im sorry :P
Never used .NET