![]() |
| | #1 |
| Registered User Join Date: Feb 2009
Posts: 88
| C window code - How easy is it to intergrate cmd code As a project im required to make a cmd program. The teacher said it would be better if we are able to intergrate it into a windowed program but didnt give us any information on it. If i have a CSV reader code working in cmd and i have this working window code: Code: // kjljl.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "kjljl.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_KJLJL, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_KJLJL));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_KJLJL));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_KJLJL);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
|
| spadez is offline | |
| | #2 | |
| Registered User Join Date: Mar 2005 Location: Mountaintop, Pa
Posts: 1,059
| Quote:
I would suggest that you discuss this project with your instructor for a clarification of the requirments. If in fact, a WIN32 GUI window scrolling app is required, then post your request in the Windows forum. Your instructor should also provide a lot more info on WIN32 GUI apps, particulary in the area of the various scrolling mechanisms that can be used in order to allow the students a reasonable chance of successfully completing the project. | |
| BobS0327 is offline | |
| | #3 |
| Registered User Join Date: Feb 2009
Posts: 88
| I very much appreciate the use of bold, underline, caps and red text to tell me i dont not have the skills required. The code posted above is not mine, it is an example code from a microsoft vs tutorial site. Are you saying their code is bad? |
| spadez is offline | |
| | #4 |
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| |
| cyberfish is offline | |
| | #5 | |
| Registered User Join Date: Feb 2009
Posts: 88
| Quote:
Last edited by spadez; 04-18-2009 at 09:22 PM. | |
| spadez is offline | |
| | #6 | |
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| Hmm okay I guess the search results are only visible to me... Click your user name > Statistics > "Find all posts by spadez". Quote:
| |
| cyberfish is offline | |
| | #7 |
| Registered User Join Date: Feb 2009
Posts: 88
| I really dont need to spend time looking for posts made by spadez as I am the one who created them after all. Are you trying to make some sort of point? |
| spadez is offline | |
| | #8 | |
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| Yes, the point is Quote:
| |
| cyberfish is offline | |
| | #9 | |
| Registered User Join Date: Feb 2009
Posts: 88
| Thats nice that you spent time trawling through my posts, but the question is: Quote:
| |
| spadez is offline | |
| | #10 |
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| The level of complexity of your code in other threads, if taken as an indication of your experience, suggests that you are not ready for this complex WinAPI stuff yet. So, to answer your question, it will be extremely difficult/impossible given your current experience (and presumably knowledge). This is just BobS0327's post reworded btw .That's why BobS0327 said (and I agree) this is probably not the intent of your prof/instructor, and it would be a good idea to seek clarification from him/her. Last edited by cyberfish; 04-18-2009 at 09:37 PM. Reason: typo |
| cyberfish is offline | |
| | #11 | ||
| Registered User Join Date: Feb 2009
Posts: 88
| Quote:
Quote:
| ||
| spadez is offline | |
| | #12 |
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| I apologize if it sounded like an insult. That was not the intention. Lack of experience is nothing wrong. All of us have been there, and I am still there. Out of curiosity, how would you respond, then, if someone who perceivably have only done a few hours of programming ask you "How easy is it to write a 3D MMORPG?" |
| cyberfish is offline | |
| | #13 | |
| Registered User Join Date: Feb 2009
Posts: 88
| Is the complexity of making a simple window app really comparable? Bob hit the nail on the head with: Quote:
| |
| spadez is offline | |
| | #14 | |||
| Registered User Join Date: Dec 2006 Location: Canada
Posts: 2,012
| Quote:
Quote:
Quote:
How would you suggest I convey this information in the future then so no one will be offended? (this is a genuine question, since English is really not my forte, and I don't want to unintentionally offend anyone) Thanks. | |||
| cyberfish is offline | |
| | #15 | |
| Registered User Join Date: Mar 2005 Location: Mountaintop, Pa
Posts: 1,059
| Quote:
Can someone help me, I'm trying to learn C?. Need I say more? The mods should move this script kiddies post over to the Windows forum where it belongs. | |
| BobS0327 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Button positioning | Lionmane | Windows Programming | 76 | 10-21-2005 05:22 AM |
| OpenGL Window | Morgul | Game Programming | 1 | 05-15-2005 12:34 PM |
| my wndProc is out of scope | Raison | Windows Programming | 35 | 06-25-2004 07:23 AM |
| opengl code not working | Unregistered | Windows Programming | 4 | 02-14-2002 10:01 PM |
| Winamp Vis if anyone can help | Unregistered | Windows Programming | 6 | 01-27-2002 12:43 AM |