Page 2 of 2

Re:Win32 app in C++

Posted: Mon Oct 28, 2002 11:39 am
by ark
Forgot to mention a couple things...in order for you to actually display a picture, you'll need to modify the IDM_NEW handler in the WM_COMMAND handler and change the file name in the pic.LoadFromFile() method call.

You'll also need to make sure the symbol WIN32 is defined when you compile, or else the method CPicResource::DrawPicToDC() will be considered undefined by the compiler.

Re:Win32 app in C++

Posted: Fri Nov 22, 2002 2:26 pm
by Kon-Tiki
I've got some more questions:

1) How do I set up a canvas?
2) How can I link other files to one file? (like new-->go to new.cpp)
3) How can I make the 'ok'-button do something else than the 'cancel'-button in a messagebox?

Thanks

-Kon-Tiki-

Re:Win32 app in C++

Posted: Sun Nov 24, 2002 10:45 am
by ark
1) How do I set up a canvas?

I'm not really sure what you're asking about. If you're using the Win32 API there are no "canvases", there are only device contexts, and the only thing you need to do to set one up for your window is create the window. Then you can access it like this:

HDC hdc = GetDC(hwnd);

where "hwnd" is the window handle for the window you're trying to paint on. Once you're done with it, you have to release it like this:

ReleaseDC(hwnd, hdc);

2) How can I link other files to one file? (like new-->go to new.cpp)

Again, I'm not really sure what you're asking about here. Using #include might do what you want, or using an extern declaration might do what you want, or you might be talking about the post-compilation step called linking.

3) How can I make the 'ok'-button do something else than the 'cancel'-button in a messagebox?

Do you mean in a message box created by MessageBox()? In that case, you simply check the return value of message box and do something different depending on the return value, as in:

Code: Select all

int nResult;

nResult = MessageBox(hwnd, "This will delete the file.", "Confirm delete", MB_OKCANCEL);

if (nResult == IDOK)
{
  // delete the file
}
else
{
  // don't delete the file
}

Re:Win32 app in C++

Posted: Sun Dec 01, 2002 8:39 am
by Kon-Tiki
Ok, had some time to try those things out. The int nResult;-thing works perfectly, but I can't figure out how to use the HDC-thing. It says 'is not declared (use function first)'. I'm going to look at some more tutorials for this one.

Joel: if you want to see how far it's getting, I'll zip it and post it here (the main window's ready, now to make it a picture-program :) )

-Kon-Tiki-

P.s. What I meant by linking source-files, is that you have one main source file (main.cpp) and, at a certain time, it needs to use another source file (eg. other.cpp), so it should switch from main.cpp to other.cpp.

Re:Win32 app in C++

Posted: Sun Dec 01, 2002 2:26 pm
by Andrew_Baker
Does VC++ support makefiles? Anyway, you don't really switch from main. Main is the core. However, if you call functions from "other.cpp" and #include <other.cpp> in your main program file or have it included in your makefile, then it should link itself, yeah?

Re:Win32 app in C++

Posted: Mon Dec 02, 2002 6:31 am
by Tim
Kon-Tiki: I suggest you go and learn, in this order:
1) Your development environment, to find out how to use more than one file in a project.
2) The Windows API: not just the names of functions, and how they work, but the fundamental principles.

For (1), use the Help menu, assuming you're using VC++.
For (2), get a copy of the book Programming Windows by Charles Petzold.

Until you do that, you will be wasting your time asking questions here. This board is no substitute for real learning.

Re:Win32 app in C++

Posted: Fri Jun 27, 2003 7:06 pm
by Kon-Tiki
Although this thread is unbelievably old, I feel that it needs to be called back. Now that I know how to write to files, I can start focussing on learning how to do the next steps for this program. I know that someone else is working on a Windows Picedit too, but that can still take a while, since he's busy up to stress in real life. I understand that this project'll take quite some time too, but I won't let myself get discouraged by one guy's opinion again. I'm going to learn what I need to be able to make what I want and make it.

Joel, if you read this thread, do you want to get back in this? You were a tremendous help back then and I know that you will be now. Just know that you'll be stuck with some weird newbie questions.

Any other programmer that wants to join, post here. We can use all the people we can. The more people we have, the less work it is and the faster the project's finished with a high quality.

Thanks

-Kon-Tiki-

Re:Win32 app in C++

Posted: Sat Jun 28, 2003 12:07 am
by ark
If you have any questions about the win32 programming or the picture resource format, ask 'em here, and if I know the answer I'll respond.

I won't be able to get any more involved with the project than that, though, if that's what you were asking. Got too many other things going on.

Re:Win32 app in C++

Posted: Sun Jun 29, 2003 12:22 pm
by anubis
i would like to join too n I have worked with VC++ for more than a year.

Re:Win32 app in C++

Posted: Sun Jun 29, 2003 1:58 pm
by Kon-Tiki
Ok, up 'till now, it's a team of three and a guru ;D
Two weeks, that means when I'm on Scouts camp...
Better divide the work for now, so that everyone can work on their part when they have the time for it.

This's what needs to be done first:

1) Setting up the drawing area (both visual and priority)
2) Making/finding the basic tools
3) Making/finding the palet
4) Enabling saving/loading/etc

Those're the things that need to be done first. Tools for drawing circles, tracing backgrounds, etc can be done after that.

Hmmmm... maybe we should wait until there's one more person in the team. I'll try to put every part together into one program if I'm able to (Joel, you'll get plenty of questions on this one ;) )

If someone's wondering why I put finding in the list, if there's already something made that can be used, there's no need to code it from scratch again. Just need to implement that then.

So, at least one more person and we're back in business again.

-Kon-Tiki-