|
No, It serves to demonstrate that if I draw the board first, the pieces will not show up, and that by drawing the piece first and then the board, all shows up.
|
|
|
|
|
BigSteve-O wrote: if I draw the board first, the pieces will not show up, and that by drawing the piece first and then the board, all shows up.
Then why do you try to draw first the board?
|
|
|
|
|
OK, I was able to reproduce your issue, and with a bit of luck, to fix it.
The problem arises when you change the DC mapping mode. Now while I am not an expert of mapping modes, this code displays the bitmap over the empty board:
Inside OnDraw (is actually OnPaint in my test app)
drawEmptyBoard(&dc);
drawImage(&dc, 105, -105);
While drawImage becomes
::drawImage(CDC* pDC, int x, int y)
{
CBitmap bmp;
if (bmp.LoadBitmap(IDB_LADYPIC))
{
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SetMapMode(pDC->GetMapMode());
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
pDC->StretchBlt(x, y, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,0, 0, bmpInfo.bmWidth, -bmpInfo.bmHeight, SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
}
}
To make things more explicit, I would move the SetMapMode call out of drawEmptyBoard .
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Thank you so much for your suggestions. It is much appreciated!
I am going to try it soon.
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Restoring the old bitmap should happen on the MemDCLady DC where you called the first SelectObject() , not the one passed in as pDC .
|
|
|
|
|
I tried the following test, just to see if i can display anything on my board,
CBitmap bitmap;
CDC dcMemory;
bitmap.LoadBitmap(IDB_LADYPIC);
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bitmap);
pDC->BitBlt(100, 200, 54, 96, &dcMemory, 0, 0, SRCCOPY);
The bitmap does not show. I only see my board.
|
|
|
|
|
pDC->SelectObject(BmpPrevious);
I do not think you should be restoring the old bitmap into pDC , since it came out of MemDCLady .
|
|
|
|
|
Been a while since I futzed with Windows drawing. There are some tricks to it.
Let me go find some old code. Right off the bat, beware working with DCs and bitmaps.
MS' implementation can be subtle.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Thank You. Appreciate it.
|
|
|
|
|
You still sucking air? I'm coming up on some free time. Turn on your profile to allow direct email.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Okay, you have an error in your code:
// Copy the bits from the memory DC into the current dc
pDC->BitBlt(20, 10, 436, 364, &MemDCLady, 0, 0, SRCCOPY);
is the culprit. Recall that you've set your coordinate system to low English which fixes the bassackwardness of drawing.
If you trace your board generation, you will see that your Y values go from 0 to negative values. Looking at the above line,
you are drawing off the top of your view window. Change the 364 to -364 and you'll see your image.
Of course, *I've* never done that
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
See my other reply.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
charlieg wrote: MS' implementation can be subtle.
I have worked with DCs bitmaps, icons etc over many years using MFC, GDI and GDI+, and never had a problem, other than with my own mistakes.
|
|
|
|
|
Truth in your statement, but I cut my graphics teeth in X-Windows which seemed to be much more logical than MS' implementation.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
it would be polite to let us know if things are working now...
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
the following problem:
F&W Sdn Bhd is a packaging company. Write a program in C++ to help the company determine how many boxes that are needed for an item. For example, a boxof shampoo can have 30 bottles in it. 95 bottles of shampoo need to be packed into 3 boxes and 5 are left.
The number of each item and the number of an item that can be packed in a box are received as inputs. Display the number of boxes needed and the number of leftover items.
|
|
|
|
|
and?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
You need to show the code you have written, and explain what the problem is, in order for people to help you. But I am afraid no one is going to write your complete assignment for you.
|
|
|
|
|
If you are serious about learning to do this yourself then take your assignment in small steps:
1 Write a program that displays output. The traditional first program displays "Hello World".
2 Now write a program that takes a number as input and then displays that same number as output.
3 Now write a program that takes two numbers as input and then displays those same two numbers.
4 Study how to do division in C++ so you know how to handle the dividend, the divisor, the quotient, and the remainder.
5 Now write your assignment, taking two numbers as input, doing the division, and displaying the results.
modified 9-Nov-22 13:59pm.
|
|
|
|
|
Since this is a class assignment, the best answers are ones that help you learn. You need to ask specific questions that you do not understand. The best way to get help is to show you have made a reasonable effort to figure it out.
|
|
|
|
|
Put the 5 that are left in a new box, and tell the other guy you only need 30 at a time.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
Currently I am working on an old VB6 app to be compatible with UNICODE.
This app has SSTab and within this tab, there are user control q1, q2, q3 and so on. For q1, it has the following code:
Private WithEvents q1 As VBControlExtender
Private progID As String
procId = "ALCTX10.CTX10.1"
Set q1 = Controls.Add(procId, "q1")
myTab.tab = 1
q1.Move borderSize, topMargin, myTab.Width - borderSize * 2, _
myTab.Height - borderSize - topMargin
q1.Visible = True
The procId is referring to VC++ 6 DLL. All user controls are using this DLL.
For VC++ 6 DLL, I added ",_UNICODE, UNICODE" into the preprocessor definitions under the project setting of VC++ 6.
And compiled the DLL again and then brought it back to VB6.
The problem is I am still getting the same UNICODE issue from VB6 app.
I am using a foreign version of Windows XP so it is not the font problem.
I can’t just replace this DLL with UNICODE supported TextBox or RichTextBox since there are too many things going underneath the DLL.
I would appreciate very much if anyone sheds a light on this problem. Thanks.
|
|
|
|
|
Did you test this DLL with some VC++ code (both sides must be built with _UNICODE, UNICODE)?
Did you text every exported function of this DLL if it works without any problem?
|
|
|
|