944,131 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2982
  • C++ RSS
Mar 14th, 2005
0

PUTTING C++ TO USE!!! (GUIs & MS Windows)

Expand Post »
In all my classes never taught us how to us C++

I still don't know how to put it to use

My professors taught us how to write it, but now how to use it

every program we wrote would excute some programming by inputing data or outputing data on a black "DOS" looking screen.

1. What are some of the modern day uses of C++?

2. How do you create a real application that is installed on your PC, where a GUI uses C++ to manipulate a Windows Operation System? Or is just for backend use?

3. How can I create an application that is meant to be used in a LAN Environment. Example below (client/server):

End User -> PC Hardware (i.e. Keyboard, Mouse & Monitor) -> GUI -> Processes/Executes C++ Code -> <- Data Transport Median -> Server Stores Data and Executes Code

^^^Hope that made any sense :-|
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005
Mar 14th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

Technically C++ and XP/98 Linux OSX Unix are not an intregal part of one another. C++ is just merely a tool by which you can write applications for many platforms. The scope an purpose to your classes would have been gaining knowledge how to use the language effectively. Just because you are shown how to use a circular saw doesn't make you a carpenter, but you may be the best circular saw user on the planet.

If you are interested in designing GUI applicaitons for windows, now you must study a book such as WIN32 API Superbible. Once you understand all the functions that are part and parcel of the operating enviorment of interest, maybe even OSX, Linux, Unix, Gnome, KDE and so on, then you will be on your way marrying C++ with end user applications.

Learning an operating systems API can be as ownerous as learning C++. Here is an example of a skeletal windows app.
C++ Syntax (Toggle Plain Text)
  1. #define WIN32_LEAN_AND_MEAN
  2.  
  3. #include <windows.h>
  4.  
  5. HINSTANCE hInst;
  6.  
  7. HWND MainWnd;
  8.  
  9. const char *AppName = "OLIST", *AppTitle = "Order List Lookup";
  10.  
  11. static bool CreateMainWindow (int ShowValue);
  12.  
  13. LRESULT CALLBACK MainWndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  14.  
  15. // =========================================================================================
  16.  
  17. int APIENTRY WinMain (HINSTANCE Instance, HINSTANCE PrevInst, char *CmdLine, int ShowValue)
  18.  
  19. {
  20.  
  21. MSG Msg;
  22.  
  23. Msg.wParam = -1;
  24.  
  25. hInst = Instance; // Global copy of instance handle.
  26.  
  27. if (CreateMainWindow (ShowValue))
  28.  
  29. {
  30.  
  31. while (GetMessage (&Msg, NULL, 0, 0))
  32.  
  33. {
  34.  
  35. TranslateMessage (&Msg);
  36.  
  37. DispatchMessage (&Msg);
  38.  
  39. }
  40.  
  41. }
  42.  
  43. return Msg.wParam;
  44.  
  45. }
  46.  
  47. // -------------------------------------------------------------------------------------------
  48.  
  49. static bool CreateMainWindow (int ShowValue)
  50.  
  51. {
  52.  
  53. const UINT STYLE = WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX;
  54.  
  55. const UINT EX_STYLE = WS_EX_CLIENTEDGE;
  56.  
  57. WNDCLASSEX Wc;
  58.  
  59. Wc.cbSize = sizeof WNDCLASSEX;
  60.  
  61. Wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  62.  
  63. Wc.lpfnWndProc = WNDPROC (MainWndProc);
  64.  
  65. Wc.cbClsExtra = 0;
  66.  
  67. Wc.cbWndExtra = 0;
  68.  
  69. Wc.hInstance = hInst;
  70.  
  71. Wc.hIcon = 0;
  72.  
  73. Wc.hCursor = LoadCursor (NULL, IDC_ARROW);
  74.  
  75. Wc.hbrBackground = HBRUSH (COLOR_BTNFACE + 1);
  76.  
  77. Wc.lpszClassName = AppName;
  78.  
  79. Wc.lpszMenuName = NULL;
  80.  
  81. Wc.hIconSm = 0;
  82.  
  83. if (RegisterClassEx (&Wc))
  84.  
  85. {
  86.  
  87. SIZE Wnd;
  88.  
  89. // Determine windows size based on current resolution. 38% width 75% height.
  90.  
  91. Wnd.cx = GetSystemMetrics (SM_CXSCREEN) >> 1;
  92.  
  93. Wnd.cx -= Wnd.cx >> 2;
  94.  
  95. Wnd.cy = GetSystemMetrics (SM_CYSCREEN);
  96.  
  97. Wnd.cy -= Wnd.cy >> 2;
  98.  
  99. MainWnd = CreateWindowEx (EX_STYLE, AppName, AppTitle, STYLE,
  100.  
  101. CW_USEDEFAULT, CW_USEDEFAULT, Wnd.cx, Wnd.cy,
  102.  
  103. NULL, NULL, hInst, NULL);
  104.  
  105. if (MainWnd)
  106.  
  107. return true;
  108.  
  109. }
  110.  
  111. return false; // Default return value, function failed.
  112.  
  113. }
  114.  
  115. // -------------------------------------------------------------------------------------------
  116.  
  117. LRESULT CALLBACK MainWndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  118.  
  119. {
  120.  
  121. switch (Msg)
  122.  
  123. {
  124.  
  125. // ________________________________________________________________________________
  126.  
  127. case WM_CREATE:
  128.  
  129. ShowWindow (hWnd, SW_NORMAL);
  130.  
  131. break;
  132.  
  133. // ________________________________________________________________________________
  134.  
  135. case WM_DESTROY:
  136.  
  137. PostQuitMessage (0);
  138.  
  139. break;
  140.  
  141. // ________________________________________________________________________________
  142.  
  143. default:
  144.  
  145. return DefWindowProc (hWnd, Msg, wParam, lParam);
  146.  
  147. }
  148.  
  149. return 0; // Default value for applciation handled messages.
  150.  
  151. }
I apologize for the formatting. I'm still trying to figure out the best way to copy and paste code so it will look good in this code frame
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Mar 14th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

I will be studying this closely, thanks a lot. I going to get that book, or find something online just like it.

Have you tried copying your code from Notepad?
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005
Mar 14th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

I think I've tried notepad before, but for some reason I think I used WordPad to save to a TXT file and then loaded with Notepad and copied and pasted from there. So far that is the only way I've been able to pad blanks instead of tabs.

In code snippets 1o0oBhP posted another example of a skeletal GUI app
http://www.daniweb.com/code/snippet112.html
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Mar 14th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

>every program we wrote would excute some programming by inputing data
>or outputing data on a black "DOS" looking screen.
I make a good living doing just that. In fact, I've never written a GUI or any graphical component. It's funny how everyone seems to think that they're not really programming unless pretty pictures are involved.

1) Just about anything you can think of. C++ is a popular workhorse in the computer world.

2) By learning a graphical API and writing an event driven messaging overlay of the code that does real internal processing. Your question is dreadfully vague.

3) TCP/IP is where it's at for networking. Do a google search for "beej" and see where that takes you.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Mar 15th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

Quote originally posted by Narue ...
>every program we wrote would excute some programming by inputing data
>or outputing data on a black "DOS" looking screen.
I make a good living doing just that. In fact, I've never written a GUI or any graphical component. It's funny how everyone seems to think that they're not really programming unless pretty pictures are involved.

1) Just about anything you can think of. C++ is a popular workhorse in the computer world.

can you give some examples of what you do, real life examples though. Be careful, I'm setting you up for a more specific question later
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005
Mar 15th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

>can you give some examples of what you do
I have a hand in just about everything that involves custom coding where I work. Most often I find myself upgrading our terminal software with new functionality, writing and editing code for report filtering, maintaining retail level software connectivity with central servers, addressing bug reports from everywhere, and mentoring the grunts.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Mar 15th, 2005
0

Re: PUTTING C++ TO USE!!! (GUIs & MS Windows)

Quote originally posted by Narue ...
>can you give some examples of what you do
I have a hand in just about everything that involves custom coding where I work. Most often I find myself upgrading our terminal software with new functionality, writing and editing code for report filtering, maintaining retail level software connectivity with central servers, addressing bug reports from everywhere, and mentoring the grunts.
lol@the grunts

*thinks about how lucky you are and sighs*

hey i printed out Beej's Guide and I will be reading it over pretty soon, i gotta get through this pointer and string tutorial i got from dave first. I told you this site was going to be a second home for me. And we're all roomies yeaaaaaaaaaaaaaaaaaaaaaaaah :lol:
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: exponents in c++
Next Thread in C++ Forum Timeline: Distance between 2 points





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC