creating a window based dialog

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 84
Reputation: evilsilver is an unknown quantity at this point 
Solved Threads: 1
evilsilver's Avatar
evilsilver evilsilver is offline Offline
Junior Poster in Training

creating a window based dialog

 
0
  #1
Mar 17th, 2005
ok i am a new programmer and am running in windows xp and 98 and am using the borland c++ builder 3, I am trying to make a window that will simply ask the user to input a string (called pathname) and store it to another file for use in another program. i can see a kinda outline like i explained, but have no idea how to implement it, can anyone help me?

p.s. can you guys also recomend the best compiler as well, i like the enviroment of borland but heard that there are better compilers, are there any that have the save enviroment but better?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: creating a window based dialog

 
0
  #2
Mar 17th, 2005
That's a pretty loaded question. Qualify first how you want to do it, meaning are you going to use a resource or create the dialog directly within code. Which compiler are you using now. If it's VC++ then are you using MFC. It might be an idea to post something you've already tried or a basic idea how you think it should be done and then help from whomever can be focused

Best compiler, well in 1998 when I bought VC++ 6.0 it was $700.00 Canadian. Does it make it the best one. I doubt it very much, but it's got a lot of stuff. It's been my experience the more STUFF a program has the more likely it's not very good at the job it's supposed to do. Other than that, I've used GCC and it is every bit as comprehensive as VC++, lacking IDE though (big deal). So your question should maybe be rephrased which compiler can I get for $$$, whatever your budget.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 84
Reputation: evilsilver is an unknown quantity at this point 
Solved Threads: 1
evilsilver's Avatar
evilsilver evilsilver is offline Offline
Junior Poster in Training

Re: creating a window based dialog

 
0
  #3
Mar 17th, 2005
Originally Posted by Tight_Coder_Ex
That's a pretty loaded question. Qualify first how you want to do it, meaning are you going to use a resource or create the dialog directly within code.
i think dialog directly within code, but then again i am a newby and don't really get the question, what do you mean by a resource

Originally Posted by tight_coder_ex
Which compiler are you using now. If it's VC++ then are you using MFC. It might be an idea to post something you've already tried or a basic idea how you think it should be done and then help from whomever can be focused
as i said before, i am using borland c++ builder 3, and tried using a pre started dialog, but i don't understand it (borland has it's own application making thing where i just point and click, and the code looks like this

  1. #include <vcl.h>
  2. #pragma hdrstop
  3.  
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11. : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15.  
  16. void __fastcall TForm1::Label1Click(TObject *Sender)
  17. {
  18.  
  19. }
  20. //---------------------------------------------------------------------------
  21.  
  22. void __fastcall TForm1::Edit1Change(TObject *Sender)
  23. {
  24.  
  25. }
  26. //---------------------------------------------------------------------------
  27.  
  28. void __fastcall TForm1::Button1Click(TObject *Sender)
  29. {
  30.  
  31. }
  32. //---------------------------------------------------------------------------
  33.  
  34. void __fastcall TForm1::Button2Click(TObject *Sender)
  35. {
  36.  
  37. }

or i can make it look like this (which doesn't help me at all either)

  1. object Form1: TForm1
  2. Left = 192
  3. Top = 116
  4. Width = 270
  5. Height = 130
  6. Caption = 'Form1'
  7. Font.Charset = DEFAULT_CHARSET
  8. Font.Color = clWindowText
  9. Font.Height = -11
  10. Font.Name = 'MS Sans Serif'
  11. Font.Style = []
  12. PixelsPerInch = 96
  13. TextHeight = 13
  14. object Label1: TLabel
  15. Left = 8
  16. Top = 8
  17. Width = 123
  18. Height = 13
  19. Caption = 'Enter path to save files to:'
  20. OnClick = Label1Click
  21. end
  22. object Edit1: TEdit
  23. Left = 32
  24. Top = 24
  25. Width = 121
  26. Height = 21
  27. TabOrder = 0
  28. Text = 'C:\'
  29. OnChange = Edit1Change
  30. end
  31. object Button1: TButton
  32. Left = 64
  33. Top = 56
  34. Width = 75
  35. Height = 25
  36. Caption = 'OK'
  37. TabOrder = 1
  38. OnClick = Button1Click
  39. end
  40. object Button2: TButton
  41. Left = 152
  42. Top = 56
  43. Width = 75
  44. Height = 25
  45. Cancel = True
  46. Caption = 'Cancel'
  47. TabOrder = 2
  48. OnClick = Button2Click
  49. end
  50. end
  51.  

and like i said before this is my first semester programming so don't know a lot, i can make it in a dos based thing but am really hopeing to get it as window.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: creating a window based dialog

 
0
  #4
Mar 18th, 2005
Sorry, I missed the Borland part. The first segment of code are the events that are either preset with those controls, or you selected something in a dialog box you initialize those events. The second part is what the resource editor uses to position them and other parametes. What you have on this dialog is

1 Label
1 Edit
2 Buttons

What you have to do is put code in those sections that suit your needs. For example in TFrom::Button1Click (TObject *Sender) is where you would read the contents of the edit control and write it to the file.

What you are dealing with here is what M$ refers to as MFC. I am not familiar with this (Borland) environment at all and you might be better off asking this question in
http://www.daniweb.com/techtalkforums/forum6.html
Geeks Lounge as your question is more related to using GUI and Borland.

Sorry I can't be of greater help
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 84
Reputation: evilsilver is an unknown quantity at this point 
Solved Threads: 1
evilsilver's Avatar
evilsilver evilsilver is offline Offline
Junior Poster in Training

Re: creating a window based dialog

 
0
  #5
Mar 18th, 2005
ok well i got this so far, but can't get it to work, how do i get it to see what is writen in the text field?

  1. #include <vcl.h>
  2. #pragma hdrstop
  3. #include <iostream>
  4. #include <conio>
  5. #include <fstream>
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13. : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17.  
  18. void __fastcall TForm1::OkClick(TObject *Sender)
  19. {
  20. char *path = new char [100];
  21. path = ;
  22. ofstream save;
  23. save.open("path.dat");
  24. save << path;
  25. save.close();
  26. exit(0);
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::CancelClick(TObject *Sender)
  30. {
  31. exit (0);
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TForm1::pathChange(TObject *Sender)
  35. {
  36.  
  37. }

this is:

1 label
1 edit (path)
2 buttons (ok, cancel)

(ok) saves the data in edit (unsure who to do this part)
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: creating a window based dialog

 
0
  #6
Mar 19th, 2005
In your ok button click event you have to read the contents of path. Not having used borland I'm not sure how its done, but using a WIN32 API it would be GetWindowText (hWnd, char *, int size); or in MFC path.m_text where m_text is the variable assigned to object path. So you don't need the variable path in your ok button click event.

So all you have to do is find out how to read the text from path edit control and then use save << ??? whatever that method is.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC