Author: James Swafford
Date: 09:44:35 01/30/01
Go up one level in this thread
On January 29, 2001 at 10:32:49, Eran wrote:
>
>I plan to create a new chess program based on MFC in Visual C++ 6 Pro. Though I
>am a beginner, I try to develop both the interface and the chess engine.
>
>I knew how to put a chessboard picture on a dialog box using picture control in
>the Dialog Editor. Besides, the dialog box could become like an overlapped
>mainframe window. However, I was not sure whether the dialog box was the right
>place to hold the chessboard picture. So, I tried to put it on a frame window
>instead of the dialog box. Unfortunately, I wrestled with the problem of how to
>put the picture on it. Moreover, I could not find a solution in the MSDN Library
I assume you have a bitmap on disk that you're wanting to load into
a window. If this is the case, instantiate a CBitMap. In the Galahad
GUI, I created an entire Display class with several CBitMap members.
I only instantiate the Display class one time, one program initialization.
Somewhere in the Display constructor, load your bitmaps into the
CBitmap members. There are routines within the CBitmap class
to display your image, resize, etc. Install the Galahad GUI and
look in the source tree for display.cpp and/or galahad.cpp (been a
while since I've looked at it.)
I did run into a strange problem at one time when I was instantiating a
CBitmap to display an image, then letting it go out of scope, then
instantiating them again when I needed them. My available memory went o nothing
and the program would eventually crash. Seems MFC wasn't releasing
the memory. Not sure. Anyway, once moved the CBitmaps someplace
where they would only be instantiated _once_ and reused, that bug
went away. I think it's commented at the top of galahad.cpp.
Once you add the bitmaps to your project, don't forget to add the
appropriate labels in your ids.h or resource.h (or whatever) header.
>either. Further, I tried the code below but still nothing worked out in my
>programming.
>
>void CMyWinApp::OnFileNew()
>{
> LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_CHESSBOARD));
>
> BitBlt(NULL,0,0,450,450,NULL,0,0,SRCCOPY);
>}
>
>If you know how, please inform me. I will appreciate it.
>
>It seems to me that the dialog box is the only place to hold any picture, but I
>am not sure whether I am right. What will you tell me? Besides, I am aware that
>Visual C++ is not nice with interface development, but it is excellent with
>chess engine development due to the faster optimizing compiler.
>
>Furthermore, I do not know for sure whether the MFC is also designed for chess
>software development. Isn't it?
Not specifically. It's designed for developing graphical windows programs. :-)
MFC is just a wrapper around the Windows API calls.
>
>Anyway, some CCC members told me that it was much better to develop chess engine
>program in the window console. So I could spend more time only on chess engine
>development. I understand that, but I still love to create both interface and
>chess engine and I do not mind hard work for a long time. I will try it - it is
>worth a try. ;)
I would still develop the engine as a console program. You can still
develop your GUI separately. Simple is better. :-)
--
James
>
>I am eager to read your follow-up posts.
>
>Your help is greatly appreciated.
>
>Thanks in advance,
>Eran
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.