|
The source code.
Andrew McIntyre
|
|
|
|
|
Right.
From you original post (and some of your previous ones) I gather that you are looking for some kind of tutor.
You have several options:
1. Buy some books and teach yourself programming
2. Pay someone to teach you
3. Find someone who would do that for free (highly unlikely although this appears to be your preferred option)
4. Pay someone to write the code for you.
5. ...
|
|
|
|
|
No I don't need someone to write the code I need someone that can help me if I get stuck.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: No I don't need someone to write the code I need someone that can help me if I get stuck.
Fair enough. That's exactly what this site is all about. So, why don't you post the relevant part of your code with a description of what it is supposed to do and where you are stuck?
|
|
|
|
|
Thanks.
#include "MyProject.h"<br />
<br />
#define MAX_LOADSTRING 100<br />
<br />
HINSTANCE hInst;
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING];
<br />
Well, I am trying to get the code to create a Win32 client, with certain dimensions and to centre it to screen, but I have missed half of the code out because I have got stuck.
Andrew McIntyre
|
|
|
|
|
What kind of client?
I suggest you tell us what your app is supposed to do and how you want to implement it (MDI/SDI/Dialog based, etc.).
|
|
|
|
|
Well, its a Win32 Client.
Well, its hard to explain, but the application allows family and friends to connect with each other, share photos, videos, music and games in a new way. At the moment I just concentrating on the client window, and the dialog's when users launch the application.
It's not really an instant messaging, its more of a communication and sharing platform where people can upload, watch and share all their multimedia and profiles.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: Well, its hard to explain, but the application allows family and friends to connect with each other, share photos, videos, music and games in a new way. At the moment I just concentrating on the client window, and the dialog's when users launch the application.
oh boy ...
Ok, take a big breath ... I think you are aiming too high too early! That looks like an advanced project, not a beginner one.
Start from the basics, because it's not an easy projects to start with.
Get yourself a MFC beginner's book, and do the exercises, go steps by steps...
make connection between what you learn and what you want to do (user interface, behaviours, ... )
Try to emulate/replicate what you've learn and start from there.
This signature was proudly tested on animals.
|
|
|
|
|
I know I am only a beginner but I am not completing the project myself. I already have other people to finish the advanced stuff for the project off already I am only doing the basics if you know what I mean. It will all make sense later, you just need to trust me.
Thanks
Andrew McIntyre
|
|
|
|
|
Okay. I have started to write the code for the Win32 client, but I may need help along the way as was wondering if you guys will be willing to help me if I get stuck,
Thanks
Andrew McIntyre
|
|
|
|
|
 When I wrote the code I had 1 failed error. Here the code for the Client, and if someone could tell me what I have done wrong.
#include <windows.h><br />
<br />
const char g_szClassName[] = "MyProject";<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(msg)<br />
{<br />
case WM_CLOSE:<br />
DestroyWindow(hwnd);<br />
break;<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
default;<br />
return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}<br />
return 0;<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
WNDCLASSEX wc;<br />
HWND hwnd;<br />
MSG Msg;<br />
<br />
wc.cbSize = sizeof (WNDCLASSEX);<br />
wb.style = 0;<br />
wc.lpfnWndProc = WndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInstance;<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = g_szClassName;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
<br />
if(!RegisterClassEx(&wc))<br />
{<br />
MessageBox(NULL, "Window Registration Failed!", "Error",<br />
MB_ICONEXCLAMATION | MB_OK);<br />
return 0;<br />
}<br />
<br />
hwnd = CreateWindowEx(<br />
WS_EX_CLIENTEDGE,<br />
g_szClassName,<br />
"The title of my window",<br />
WS_OVERLAPPEDWINDOW,<br />
CW_USERDEFAULT, CS_USERDEFAULT, 903, 729,<br />
NULL, NULL, hInstance, NULL);<br />
<br />
if(hwnd == NULL)<br />
{<br />
MessageBox(NULL, "Window Creation Failed", "Error!",<br />
MB_ICONEXCLAMAION | MB_OK);<br />
return 0;<br />
}<br />
<br />
ShowWindow(hwnd, nCmdShow);<br />
UpdateWindow(hwnd);<br />
<br />
while(GetMessage(&Msg, NULL, 0,0) > 0)<br />
{<br />
TranslateMessage(&Msg);<br />
DispatchMessage(&Msg);<br />
}<br />
return Msg.wParam;<br />
}<br />
Thanks.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: When I wrote the code I had 1 failed error
I get 5 or 6 when I try to compile this (VC6, 2003 Platform SDK). The switch statement is screwed up, you're using non-existing window styles, typos, etc.
All I see is a pretty standard Win32 application skeleton that just creates a window and a message loop. Well, it would if you fixed all the obvious errors.
Don't get me wrong - I don't want to discourage you from writing this program but you're getting way ahead of yourself. Once you really understand what the above code does (and know how to fix the errors) you can start putting in your own code.
modified on Sunday, October 4, 2009 5:42 PM
|
|
|
|
|
It's alright. I got the application to work perfectly now.
Andrew McIntyre
|
|
|
|
|
Does anyone know a code to centre the Win32 client to the screen. Just brushing up on a few minor things. Please forgive if I ask too many questions.
Thanks
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: Does anyone know a code to centre the Win32 client to the screen.
If you are using MFC, CenterWindow() . If not, you can still consult its source code to see how it is handled.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Is that the full line of code? If so, where would I place it in the source code.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: Is that the full line of code?
Did you consult the documentation (or the source code)?
MrMcIntyre wrote: If so, where would I place it in the source code.
At the point you want the window centered. After the window has been created but before it is rendered would be a good place to start (hint: WM_CREATE ).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
What documentation, I haven't read any documents
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: What documentation, I haven't read any documents
And how many times must I suggest that you do, before the message sinks in?
|
|
|
|
|
But I haven't saw any documentation what ones, it could be any on this website or others.
If there is documentation send me a link.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: If there is documentation send me a link.
I suggest you start with MSDN[^], which has information on just about everything you need to write Windows applications. Read articles here on Code Project, as I said before there are some excellent beginner's guides. Use Google to search for specifics on the subjects you are interested in.
Above all understand that no project can be produced without a lot of hard work.
|
|
|
|
|
In response to the WM_CREATE message, consider calling MoveWindow() or SetWindowPos() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I really don't understand what you are saying. I could not find WM_CREATE message in my code anywhere.
Could you write the line of code just quickly so I see how it works and I will figure out where to put it.
Thanks
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: I really don't understand what you are saying. I could not find WM_CREATE message in my code anywhere.
Could you write the line of code just quickly...
Does Google not work in your area? See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
MrMcIntyre wrote: I really don't understand what you are saying. I could not find WM_CREATE message in my code anywhere.
Could you write the line of code just quickly so I see how it works and I will figure out where to put it.
Andrew, from the structure of your sentences I suspect that English is your first language. However from the content, including the second line above, I would suspect that you are very much a beginner to Windows programming, possibly C++, and possibly even programming itself. You seem to be approaching this problem in totally the wrong way, as you seem to believe that you are going to create this project by asking questions on this forum and building the program one line at a time, without really understanding the code you are putting together. I have recommended you a number of times to buy some books, use the tutorials on this site (and MSDN and Google) to learn the basics and write some simple programs so that you can at least understand the concepts of windows, dialogs, message passing, menus, controls etc.
You may be under the misapprehension that people here are being delibarately obstructive in their answers; nothing could be further from the truth. Everyone here wants to help each other, but they can only help you fix things after you have created your program(s). Nobody here has the time to write your code, or teach you how to do it.
|
|
|
|
|