|
How can i make a CBitmap on top of other control.
As I instantiated and display the bitmap, it appears
behing a control.. I wanted it to be on top of other
control and the control where the bitmap is displayed
is behind the bitmap. HOw can i do it?
More Power!
|
|
|
|
|
What's the difference between having a variable for incrementing, like
int Wins;
++Wins;
or
Wins++;
Also, when do you use ++Wins or Wins++?
|
|
|
|
|
Well, one is a pre-increment and the other is a post increment. When used inside a complex statement, it does matter which one you use.
For example:
int c = *p++; // get the character and then increment the pointer
int c = *++p; // increment the pointer and then get the character
For the most part, when standing by itself, it doesn't matter which you use. However, on complex objects, pre-increment can perform a lot better than post-increment.
For example - assume we needed to implement pre and post increment for a class.
pre-increment:
value = value + 1;
return value;
post-increment:
oldvalue = value;
value = value + 1;
return oldvalue;
As you can see, to do a post-increment, you first have to make a copy of the value so it can be returned to the caller. The good news is that most optimizers will optimize it away if you aren't interested in the return value. (for example, in a "for" statement)
So which should you use? If it doesn't matter, get use to using pre-increments.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
If it doesn't matter, get use to using pre-increments.
I'm thinking "STL iterators"!
|
|
|
|
|
i would also prefer
pre-increments
if i have a option .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
its not a matter of preference , its the need.
Every man should marry. After all, happiness is not the only thing in life.
--[v]--
|
|
|
|
|
Good day,
I have made a class that can display a bitmap with transparance (i.e. display bitmap image except for the unwanted color is not displayed). It works fine in Visual C++.
Now i'm porting the class to Embedded VisualC++(EVC3.0) however There is not CDC::SetMapMode in EVC3.0. Anybody knows what is its equivalent?
Anyway here is my code in Visual C++, class CMyBitmap derived public from CBitmap and Draw function and has DrawTransparent function... In the code here I've just comment the CDC.SetMapMode code...
Anybody have suggestion?
Thanks.
void CMyBitmap::Draw(CDC *pDC, int x, int y)
{
BITMAP bm;
GetBitmap (&bm);
CPoint size (bm.bmWidth, bm.bmHeight);
pDC->DPtoLP (&size);
CPoint org (0, 0);
pDC->DPtoLP (&org);
CDC dcMem;
dcMem.CreateCompatibleDC (pDC);
CBitmap* pOldBitmap = dcMem.SelectObject (this);
//dcMem.SetMapMode (pDC->GetMapMode ());
pDC->BitBlt (x, y, size.x, size.y, &dcMem, org.x, org.y, SRCCOPY);
dcMem.SelectObject (pOldBitmap);
}
void CMyBitmap::DrawTransparent(CDC *pDC, int x, int y, COLORREF clrTransparency)
{
BITMAP bm;
GetBitmap (&bm);
CPoint size (bm.bmWidth, bm.bmHeight);
pDC->DPtoLP (&size);
CPoint org (0, 0);
pDC->DPtoLP (&org);
CDC dcImage;
dcImage.CreateCompatibleDC (pDC);
CBitmap* pOldBitmapImage = dcImage.SelectObject (this);
//dcImage.SetMapMode (pDC->GetMapMode ());
CDC dcAnd;
dcAnd.CreateCompatibleDC (pDC);
//dcAnd.SetMapMode (pDC->GetMapMode ());
CBitmap bitmapAnd;
bitmapAnd.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);
CBitmap* pOldBitmapAnd = dcAnd.SelectObject (&bitmapAnd);
dcImage.SetBkColor (clrTransparency);
dcAnd.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y,
SRCCOPY);
CDC dcXor;
dcXor.CreateCompatibleDC (pDC);
//dcXor.SetMapMode (pDC->GetMapMode ());
CBitmap bitmapXor;
bitmapXor.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight);
CBitmap* pOldBitmapXor = dcXor.SelectObject (&bitmapXor);
dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y,
SRCCOPY);
dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y,
0x220326);
CDC dcTemp;
dcTemp.CreateCompatibleDC (pDC);
//dcTemp.SetMapMode (pDC->GetMapMode ());
CBitmap bitmapTemp;
bitmapTemp.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight);
CBitmap* pOldBitmapTemp = dcTemp.SelectObject (&bitmapTemp);
dcTemp.BitBlt (org.x, org.y, size.x, size.y, pDC, x, y, SRCCOPY);
dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y,
SRCAND);
dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcXor, org.x, org.y,
SRCINVERT);
pDC->BitBlt (x, y, size.x, size.y, &dcTemp, org.x, org.y, SRCCOPY);
dcTemp.SelectObject (pOldBitmapTemp);
dcXor.SelectObject (pOldBitmapXor);
dcAnd.SelectObject (pOldBitmapAnd);
dcImage.SelectObject (pOldBitmapImage);
}
|
|
|
|
|
Hi for all
I would like to know what exactly are the HWND, HINSTANCE, HDC and HGLRC variables, when I use one or another and teh differences among them.
I've read the msdn but I didn't understand nothing.
Thanks for explanations
Alex Cutovoi
|
|
|
|
|
Alex Cutovoi wrote:
I would like to know what exactly are the HWND, HINSTANCE, HDC and HGLRC variables, when I use one or another and teh differences among them.
I've read the msdn but I didn't understand nothing.
What answers did you not understand a couple of days ago when you asked the question the first time?
Simple question[^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
A couple of days ago the answer that send me is that the only just 32 bit variables and nothing more. I would like more explanations, like when I use one or another and this differences. That's it.
Thanks
|
|
|
|
|
Alex Cutovoi wrote:
A couple of days ago the answer that send me is that the only just 32 bit variables and nothing more. I would like more explanations, like when I use one or another and this differences. That's it.
Okay lets try this,
HWND (from memory)
All windows are assigned a handle (at run time) a unique integer that identifies them. By window I mean virtually everything that a user could interact with, edit controls, static controls, command buttons, tool bars (the object on the tool bar as well), dialog windows, the main frame of a SID / MDI app, system tray, the desktop. Etc. the list goes on.
HDC (stolen from Winprog.org[^] )
Is basically a handle to something you can draw on; it can represent the entire screen, an entire window, the client area of a window, a bitmap stored in memory, or a printer. The nice part is that you don't even need to know which one it refers to, you can use it basically the same way, which is especially handy for writing custom drawing functions which you can then use on any of these devices without changing it for each one.
HGLRC (this one I had to look up, as its part of OpenGL a graphics library)
given an HDC with an appropriate pixel format, we can make a Handle to an openGL Rendering Context (HGLRC)
See OpenGL_Windows_Setup[^]
Hope that provides a little more insite...
DEBUGGING : Removing the needles from the haystack.
-- modified at 9:58 Thursday 6th October, 2005
|
|
|
|
|
thanks peter for the support. The things are more clear now.
|
|
|
|
|
Alex Cutovoi wrote:
thanks peter for the support.
No problem Bob, glad to help.
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I have a class project due in 1 week. My professor won't be back until a day before it's due. Does a switch statment have to have a default? Probably a dumb question, but the way I designed the application there is really no need.
|
|
|
|
|
it does not matter. as long as ur app can run smootly
<< >>
|
|
|
|
|
No, it's not required. It's often considered good practice to include one anyway, and if you don't expect it to ever be hit to fill it with an assert(false) or other such code to notify you, as a sanity check.
|
|
|
|
|
|
Hi
I know how to assign the window for the status of messages in Http request as:
CHttpSession *pHttpSession;
pWnd = GetDlgItem(IDC_EDIT_RESPONSE);
pHttpSession->SetStatusWnd(pWnd);
How can write these messages into a LOG file instead to a window? Any suggestion please. I have to insert all the messages from Http to the Log file.
Thanks in advance
Shailesh
|
|
|
|
|
Can u get the content of the edit control?
if so, just simpy write it to log file using CFile class
<< >>
|
|
|
|
|
no Edit control does not exist in the picture
Any more suggestion
shailesh
|
|
|
|
|
Couldn't find CHttpSession neither in the documentation nor in the MFC include/source files. I only have VS2005 in this machine; maybe this class was in VC98 and was later removed from MFC? I'll check in a VC98 installation I have in another computer but that won't be until tomorrow.
Meanwhile, I'm guessing CHttpSession is/was a class derived from CInternetSession. Am I right? If so, check your MFC source files to see what use CHttpSession makes of the window you pass in SetStatusWnd. My guess is that the window is being used in CHttpSession's implementation of OnStatusCallback (i.e., constructing a message text based on the callback parameters and then simply calling SetWindowText on the window). You might create your own class derived from CHttpSession and override OnStatusCallback in such a way that the messages are written to a log file.
Other than that, you might also create a derived CWnd class to be used as the status window. You can make that window not visible (i.e., ShowWindow(SW_HIDE); ) but trap all WM_SETTEXT messages to redirect the text to your log file.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi, all
I kinda fixed the issue but still not sure what's wrong with the previous method.
it was having access violation at this point:
void CSurchrgDlg::Exit()
{
if( !m_bCanceled )
{
.....
}
CDialog::OnCancel();
}
now I used "PostMessage( cDlg->GetSafeHwnd(), WM_QUIT, 0, 0 );" replaced the exit funtion at the end of RUN. seems to work.
OR I used PostMessage(WM_QUIT); to replace CDialog::OnCancel(); would work, too.
could someone tell me what's wrong with the calling the CDialog::OnCancel();? Thank you for your time!
|
|
|
|
|
Do u mean that no thing happens when calling OnCancle() method?
if so, try to overide this ... this is just a guess
<< >>
|
|
|
|
|
thanks for your reply.
what happened was everything goes well in debug, but it crashes when it called onCancle() in release mode with access violation.
I couldn't figure out why it that, by the way, is there a outline for when to use onCancle and when for postmessage()? and for the UNICODE, what is sign for UNICODE inside of a function? thanks again!
|
|
|
|
|
valerie99 wrote:
everything goes well in debug, but it crashes when it called onCancle() in release mode
it's out of my control....
let me know also if u overcome this
<< >>
|
|
|
|
|