|
thanks.It works.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Does anyone know how to host the web browser control in an sdi app in the client rectangle using only straight com interfaces? I dont want to use htmlview
|
|
|
|
|
Then pick inside the CHtmlView code, which is MFC code provided in vcdir\mfc,
And I swallow a small raisin.
|
|
|
|
|
put the webbrowser control to the window.
classwizard generates a wrapper class for the ActiveX object.
it's usually called WebBrowser2
use its Create method to put it on the window
|
|
|
|
|
Hi all,
I have a dialog based application in which i'm loading a picture in to a static control during run time using the load image function.The problem is that after displaying the image, if i minimise and then maximise my dialog or if i switch over focus to another window and come back to my dialog the picture from my dialog dis appears. The code used for displaying bitmap is given below.Can anyone tell me what's wrong with this?
##########################################
//In Dialog Header
RECT rectStaticClient;
CDC m_dcMem; // Compatible Memory DC for dialog
HBITMAP m_hBmpOld; // Handle of old bitmap to save
HBITMAP m_hBmpNew; // Handle of new bitmap from file
BITMAP m_bmInfo; // Bitmap Information structure
CPoint m_pt; // Position for upper left corner of bitmap
CSize m_size;
##########################################
CMyDialog::OnInitDialog()
{
CClientDC dc(this);
m_dcMem.CreateCompatibleDC( &dc );
return true;
}
##########################################
CMyDialog::OnDisplay()
{
m_st3.GetClientRect( &rectStaticClient );
m_size.cx = rectStaticClient.right; // zero based
m_size.cy = rectStaticClient.bottom; // zero based
m_st3.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient );
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
CClientDC dc(this);
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew ) );
dc.StretchBlt( m_pt.x, m_pt.y, m_size.cx, m_size.cy,
&m_dcMem, 0, 0, m_bmInfo.bmWidth-1, m_bmInfo.bmHeight-1,
SRCCOPY );}
With regards
|
|
|
|
|
|
No i'm calling this function in the button click event.I wrote the same code in the onPaint() and called Invalidate() in my Button click event.But the image just views and get disappeared very immediately.So i changed it.
|
|
|
|
|
[NOT PART OF ORIGINAL MESSAGE - What happens to scrollbars when you use OnNcPaint() why do they disappear and how do I bring them back, thanx]
I have tried in the past to use these 2 painting handlers only to stop flicker in one or the other...NOT both.
I thinking it is becuz NcPaint gets called renders its display and blits it to the screen, then OnPaint does the exact same thing...(I think it's in that order).
So my question is this...
Is it possible to use one bitmap for both OnNcPaint and OnPaint...and blit the bitmap to the screen HDC at the end of OnPaint or OnNcPaint() or which ever gets called last...???
This would avoid the double double buffering and hopefully avoid flicker in both not just one...
is this possible...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I would say that it is possible, but I think that you may cause other problems because of the way that Win32 handles a windows update region. A WM_NCPAINT and WM_PAINT message are only generated when an invalid portion of the window is detected. When you get a WM_PAINT message, and you call BeginPaint, the only portion of the window that you will be allowed to paint in is the invalid region.
What I would suggest that you do is create one bitmap to represent the entire window (border and client area) and use that bitmap to update the window when you get an update message and that should accomplish what you are trying to solve.
The one other optimization that you could make (but you will have to test this) is when you get a WM_NCPAINT message, and the update region is a 1. That means that the entire window needs to be refreshed. You could possibly blt the entire bitmap to teh window, then call ValidateRect(hWnd, NULL) in order to validate the entire window. This would cancel any WM_PAINT message that you may have received because you already updated the window (once again you will have to test this to make sure that there are not any side effects.)
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I'm at a loss as to how to have flicker free drawing code in both the client and non-client...I thought maybe my mentioned approach would work. I have already got the entire control drawing flicker free but only in the client. I would like to split the control drawing though and do some in the non-client area. It would make windows messages easier to handle.
p.s-What happens to scroll bars when non-client painting is used...? Do I have to redraw them myself...???
cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I have designed a control in which is split into 2 classes.
The base class being a memory management class (MMC) with members like setText() getText(). The control is derived from CWnd and MMC. What would be the best way in terms of OOD to have the base class MMC notify the parent to refresh the display when a setText() is called...
Obviously I can't have Invalidate() inside MMC::setText because it isn't derived from CWnd it's a CObject...
Can I do this with down casting...? Currently I have an OnRefresh() handler virtual void function declared inside MMC which MMC:setText() and similar functions call...in the control (CWnd derived class) I override this member function and call invalidate from here.
Is there a better way...? Is this acceptable OOD...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Does your control derive from MMC or does it contain a MMC member variable?
If you need your control to update after each MMC function is called then I would suggest making a MMC member variable and write some wrapper functions for your control
MyControl : public CWnd
{
void setText()
{
m_MMC.setText();
Invalidate();
}
MMC m_MMC;
}
instead of
MyControl : public CWnd, MMC
{
}
Todd Smith
|
|
|
|
|
Thats how I originally implemented the control but figured the virtual method offered a cleaner more OOD friendly interface.
class MMC{
public:
setText()
{
}
protected:
virtual void OnRefresh()
{ }
};
class ctrlList : public CWnd, MMC{
public:
void OnHScroll()
{
ScrollDC();
Invalidate();
}
protected:
void OnRefresh(){ invalidate(); }
};
The above is my reasoning and current implementation...I would personally prefer deriving from MMC instead of using composition just becuz I already have way so many member variables another like m_mmcBuffer; would just add to the confusion so I figured deriving would allow for a cleaner looking code syntax.
Why would composition be your preferred way of doing things? Is the virtual OnRefresh() that big of a performance hit...?
Thanx!
cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I made a console app and made a cool class for it. Why will it not let me make an object out of the class?
I tried:
MyClass m_class;
</code>
It is giving me the following errors:
C:\Program Files\Microsoft Visual C++ 6.0 Standard Edition\MyProjects\Console Test\Console Test.cpp(6) : error C2146: syntax error : missing ';' before identifier 'Beginning'
C:\Program Files\Microsoft Visual C++ 6.0 Standard Edition\MyProjects\Console Test\Console Test.cpp(6) : error C2501: 'MyIntro' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual C++ 6.0 Standard Edition\MyProjects\Console Test\Console Test.cpp(6) : fatal error C1004: unexpected end of file found
Thanks in advance,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Not sure what 'Beginning' and 'MyIntro' are, but this looks like you forgot a semicolon in your header file. Just an idea, but did you remember the semicolon after the closing brace in your class declaration?
class MyClass
{
...
}<font color="red">;</font>
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Yes, the semiconlon is there. MyIntro is the real class name, and "Beginning" is the real object name (I just named them simply for this message board).
If anyone would like me to e-mail the code, just ask--still not sure why it's not working. You should be able to call functions (or at least make an object) from a class in a console app, right?
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Sure, send me the code and I will take a look at it. But I am almost certain that it is just a matter of a missing semicolon or possibly a closing brace somewhere.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
You've most probably made a simple coding error. The following works:
class MyIntro {};
MyIntro Beginning;
int main() { return 0; }
|
|
|
|
|
Hi,
The program I am working on is an SDI. When the program starts, I have a bitmap background active. I have created split screen windows in CMainFrame::OnCreateClient. When I try to call the split screen from one of my dialog boxes' OnOK buttons, I can not switch from the background bitmap to a split window screen. How can I best accomplish this?
Any help greatly appreciated,
CitationJet
|
|
|
|
|
You should try the ST_SplitterWnd from Daniel Zuppinger:
http://www.codeproject.com/splitter/st_splitterwnd.asp
You can add, remove, switch panes in splitted windows.
Eric
|
|
|
|
|
How can I find out which control in my formview is now focused?How can I do it with GetFocus()
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
You can use the GetDlgCtrlID() method of CWnd to determine the control ID of the current control with focus:
CWnd *pWnd = GetFocus();
int FocusID = pWnd->GetDlgItemID();
if(FocusID == IDC_MYCOMBOBOX)
; // whatever
Hope this helps,
- Nigel
|
|
|
|
|
NigelQ wrote:
pWnd->GetDlgItemID();
I got this error:
GetDlgItemID is not member of CWnd.
I test GetDlgCtrlID too but it didn't work.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Thanks.Now I make it with GetDlgCtrlID() .
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
How can i trap enter key in a derivated CEdit class.
|
|
|
|