|
is there any way to check if print button pressed in print preview?
|
|
|
|
|
hiho@ll
for simple test environment i'm using the SimpleBrowser from codeproject which uses IWEbBrowser2 to make a "self-made" webbrowser
i know it's relatively easy to control html pages using post or get or to change the input field values
but can this be done with a flash site?
the problem:
i load a flash site from the internet, which has input fields and a form (all made in flash).
so how can i fill out the flash form and send it with webbrowser2?
because it's https i can't really sniffer which content is sent
any suggestions?
thxalot
|
|
|
|
|
How to change the Coordinate Map Mode ,create a compatible DC used to draw ,then call bitblt() to show the picture?
my code in the following , But when I run it ,there is nothing to be showed!
void CTestSetMapModeView::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rect;
GetClientRect(rect);
CClientDC dc (this);
dc.SetMapMode (MM_ISOTROPIC);
dc.SetWindowExt (rect.Width (), -rect.Height ());
dc.SetViewportExt (rect.Width (), -rect.Height ());
dc.SetViewportOrg (point);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SetMapMode(MM_ISOTROPIC);
memDC.SetWindowExt(rect.Width(), -rect.Height());
memDC.SetViewportExt(rect.Width(), -rect.Height());
memDC.SetViewportOrg (point);
CBitmap bitmap,*pOldBitmap;
bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
pOldBitmap=memDC.SelectObject(&bitmap);
memDC.BitBlt(-rect.Width()/2,rect.Height()/2,rect.Width(),rect.Height(),&dc,-rect.Width()/2,rect.Height()/2,SRCCOPY);
//draw some pictures
memDC.Ellipse(-50,50,50,-50);
memDC.Ellipse(-10,20,10,-20);
dc.BitBlt(-rect.Width()/2,rect.Height()/2,rect.Width(),rect.Height(),&memDC,-rect.Width()/2,rect.Height()/2,SRCCOPY );
memDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
CView::OnLButtonDown(nFlags, point);
}
|
|
|
|
|
Antonlio,
One thing I've found interesting about Windows Programming is the level of filtering Win32 does that is quite invisible. In this case, Win32 contains some code that says "ignore all drawing unless I need to draw..." Windows makes the decision to draw if the window is invalid. If you invalidate the target window, windows will fire an On Paint message. Adjust your code accordingly, and all will be well (at least you should see something on the screen).
chg
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
I think the problem in my case is the " coordinate map ".
I don't know When I excute the following codes:
CRect rect;
GetClientRect(rect);
CClientDC dc (this);
dc.SetMapMode (MM_ISOTROPIC);
dc.SetWindowExt (rect.Width (), -rect.Height ());
dc.SetViewportExt (rect.Width (), -rect.Height ());
dc.SetViewportOrg (point);
, Whether I should also change the memDC's coordinate map mode ,just like the following :
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SetMapMode(MM_ISOTROPIC);
memDC.SetWindowExt(rect.Width(), -rect.Height());
memDC.SetViewportExt(rect.Width(), -rect.Height());
memDC.SetViewportOrg (point);
aa
|
|
|
|
|
The aim of my case is to paint picture in the memory-DC (compatible DC) ,for preventing glitter when refresh(repaint)!
And I choose the maths coordinate mode not the MM_TEXT .That is X-axis ascending from left to righgt while Y-axis from bottom to top!
|
|
|
|
|
Antonlio,
My exposure to date with Win32 is through Windows CE, and Windows CE does not support the different mapping modes. I cannot comment further regarding that issue. I understand what you are doing - it's called double buffering and a host of other names. What I would do is divide and reduce the issue. Just add some code that slaps something silly onto the page in the default mode. If that doesn't show up, it isn't your scaling, it's what I mentioned earlier...
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
CharlieG :
Thank you very much !
I have solved this question by now ,the key of which is the ordinate of the MemDC should be set correct .
Antonliox
|
|
|
|
|
My pleasure. Code on....
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
Drawing inside OnLButtonDown() is not a good approach.
All drawing should be done in YourView::OnDraw() , based on the document's content, and possibly some state you keep in YourView .
At OnLButtonDown() , or for that matter, at the handler of any command that represents user interaction, you should alter the data in the document or the state of your view. If you alter the document, you should make the document notify the views about that fact (see CDocument::UpdateAllViews() ).
The view receives the document's notifications through OnUpdate() . The notification may include additional data that narrows what kind of modification was done and to what extent, so that each view can optimize the work needed to update the drawing. In the more general case, the view just calls Invalidate() , so as to redraw the entire window next time OnDraw() is invoked. Depending on the hint received, it may go for invalidating only a portion of the drawing.
Going back to OnDraw() , you can just draw everything (Windows will only update the invalidated portions of the window, anyway), or you may optimize the drawing by excluding portions of the drawing you know are out of the visible portion of the window, or are not invalidated.
Now, the best place to deal with mapping modes is at YourView::OnPrepareDC() , which the framework will always call before calling YourView::OnDraw .
Drawing to an offscreen bitmap to avoid flickering can be done, for example, in the following way. It's based in some working code but since I modified it for this post and haven't actually tested it, I can't guarantee that it works or even that it compiles, but I hope it helps, anyway:
void CYourView::OnDraw(CDC* pDC)
{
CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap = NULL;
CRect client;
if (pDC->GetClipBox(client) == NULLREGION)
return;
CRect rect = client;
dc.LPtoDP(rect)
if (!pDC->IsPrinting())
{
if (dc.CreateCompatibleDC(pDC))
{
if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
{
OnPrepareDC(&dc, NULL);
pDrawDC = &dc;
dc.OffsetViewportOrg(-rect.left, -rect.top);
pOldBitmap = dc.SelectObject(&bitmap);
dc.SetBrushOrg(rect.left % 8, rect.top % 8);
dc.IntersectClipRect(client);
}
}
}
DoTheActualDraw(pDrawDC);
if (pDrawDC != pDC)
{
pDC->SetViewportOrg(0, 0);
pDC->SetWindowOrg(0,0);
pDC->SetMapMode(MM_TEXT);
dc.SetViewportOrg(0, 0);
dc.SetWindowOrg(0,0);
dc.SetMapMode(MM_TEXT);
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
dc.SelectObject(pOldBitmap);
}
}
void CYourView::DoTheActualDraw(CDC* pDC)
{
CYourDocument* pDoc = (CYourDocument*) GetDocument();
CRect rEllipse = pDoc->GetEllipsePositon();
if (pDC->RectVisible(rEllipse))
pDC->Ellipse(rEllipse);
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi Jose:
Thank you very much .What you have said is much useful !
AntonlioX
|
|
|
|
|
AntonlioX wrote:
Thank you very much .What you have said is much useful !
You are welcome! Glad to be of help.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
Iam using Keith Rule's CMemDc class & I have changed it according to my requirement.Iam posting that class also here.
Now Iam zooming my View using "SetWorldTransform" call.
My problem now is when I change the zoom factor to below or above 100,the Fonts are not smooth.
The following are my codes:
//Creating Font like this in "MyView" constructor.Don't want to use FixedFonts.
m_oFont.CreatePointFont(120, _T("Courier New"));
LOGFONT oLogfont;
m_oFont.GetLogFont(&oLogfont);
//OnPrepareDc looks like this.
void MyView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
pDC->SetMapMode(MM_TEXT);
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);
pDC->SelectObject(&m_oFont);
pDC->GetTextMetrics(&m_TextMetrics);
XFORM xForm;
xForm.eM11 = 0.01 * m_iZoomFactor;
xForm.eM21 = 0;
xForm.eDx = 0;
xForm.eM12 = 0;
xForm.eM22 = 0.01 * m_iZoomFactor;
xForm.eDy = 0;
pDC->GetTextMetrics(&m_textMetrics);
SetWorldTransform(pDC->GetSafeHdc(), &xForm);
CScrollView::OnPrepareDC(pDC, pInfo);
}
//My "OnDraw" looks like this.
void MyView::OnDraw(CDC* pDC)
{
CpagesDoc* pDoc = GetDocument();
CSize sizeTotal;
//default scrollsizes to 80 chars X 80 lines.
sizeTotal.cx = 80;
sizeTotal.cy = 80;
//Client Rectangle Size.
CRect rect;
GetClientRect(&rect);
//Creating a temporary Dc.
C_TempDc tempDC(pDC,m_oFont,&rect);
int pageWidth = 800;
int pageHeight = 800;
//int pageGap = 5;
int pageNumber =3;
SIZE size;
size.cx = 1000;
size.cy = (pageHeight*3)+100;
//First Page
tempDC->Rectangle(CRect(0,0,pageWidth,pageHeight));
tempDC->TextOut(5,10,"This is the first line on the FirstPage");
sizeTotal.cx *= MulDiv(m_textMetrics.tmAveCharWidth, m_iZoomFactor, 100);
sizeTotal.cy *= MulDiv(m_textMetrics.tmHeight, m_iZoomFactor, 100);
SetScrollSizes(MM_TEXT, sizeTotal);
}
//Keith Rule's Memory Buffer
#ifndef C_TEMPDC_H
#define C_TEMPDC_H
class C_TempDc : public CDC
{
public:
C_TempDc(CDC* pDC,CFont & font,const CRect* pRect = NULL): CDC()
{
ASSERT(pDC != NULL);
//Initialising.
m_pDC = pDC;
m_oldBitmap = NULL;
m_oldFont= NULL;
//Getting ClipBox Rectangle.
pDC->GetClipBox(&m_clipRect);
//Client Rectangle.
m_clientRect = *pRect;
pDC->DPtoLP(&m_clientRect);
// Create a Memory DC
CreateCompatibleDC(pDC);
//pDC->LPtoDP(&m_rect);
m_bitmap.CreateCompatibleBitmap(pDC,m_clientRect.Width(),m_clientRect.Height());
pDC->LPtoDP(&m_clientRect);
m_oldBitmap = SelectObject(&m_bitmap);
///Selecting the Font.
m_oldFont = SelectObject(&font);
SetMapMode(pDC->GetMapMode());
pDC->DPtoLP(&m_clientRect);
SetWindowOrg(m_clientRect.left,m_clientRect.top);
// Fill background
FillSolidRect(m_clientRect, pDC->GetBkColor());
}
~C_TempDc()
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_clipRect.left,m_clipRect.top,m_clipRect.Width(), m_clipRect.Height(),
this, m_clipRect.left,m_clipRect.top, SRCCOPY);
//Swap back the original bitmap & font.
SelectObject(m_oldBitmap);
SelectObject(m_oldFont);
}
C_TempDc* operator->()
{
return this;
}
operator C_TempDc*()
{
return this;
}
private:
CBitmap m_bitmap;
CBitmap* m_oldBitmap;
CFont* m_oldFont;
CDC* m_pDC;
CRect m_clientRect;
CRect m_clipRect;
};
#endif//C_TEMPDC_H
Hope u can Help....
|
|
|
|
|
Hi, for quite sometime, I use CList to store my non CObject derived class pointer.
CList<cmyclass*, cmyclass*=""> MyPtrList;
However, I remember saw in an article that the author suggest to use
CTypedPtrList<cptrlist, cmyclass*=""> MyPtrList;
However, I am not quite remember the reason to do so and not to use CList to store the pointer of non-CObject class.
Does anyone know why we need to do so?
Thanks.
cheok
|
|
|
|
|
yccheok wrote:
However, I am not quite remember the reason to do so and not to use CList to store the pointer of non-CObject class.
I believe, There is no particular reason not store Non COBJECT drived class in CList.
you can store almost Everything using CList.Let take example:-
int is not derived from CObject, even not a class,it's a keyword but you can store it using CList without nay extra overhead and difficulty.
I can't find any reason for not using CList for Non CObject derived class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello, I have an object called XXX previously derived from CDocument in my MDI project.
Later, I create an concrete class called Subject. And I let XXX to have multiple inheritance from Subject (Subject is an object with protected constructor)
The problem is, whenever I used dynamic_cast to cast a Subject pointer to XXX (I am quite sure Subject pointer is actually pointing to XXX), a visual c++ runtime error will occur.
void fun(Subject *s) {
XXX *var = dynamic_cast<xxx *="">(s);
var->hehehe();
}
However, when I try to do this:
void fun(Subject *s) {
XXX *var = (XXX *)(s);
var->hehehe();
}
everything just go fine. may i noe why this happen? is this bug related to something called dynamic creation?
thanks you.
cheok
|
|
|
|
|
Hi,
Have you tried enabling RTTI for your project ?
When it's enabled, instead of throwing an exception, the dynamic_cast will return NULL (make sure you check the return value! )
Hope this helps
|
|
|
|
|
Can you please let me know how I can enable RTTI for the project? Please note that for the classes which my CDocument inheritance from, I created by hand.
Here is my details:
I have an abstract class named CObserver and a concrete class named CSubject. The purpose of having this two classes is that, some interesting event will always happen in subject. observer is a guy which is interested in the event in subject. subject will notify all the observers attached to it whenever an event happen.
---------------------------------------------------------------------
class CObserver {
public:
virtual ~CObserver();
virtual void Update(CSubject *s) const=0;
protected:
CObserver();
};
class CSubject {
public:
virtual ~CSubject();
virtual void Attach(CObserver *o);
virtual void Detach(CObserver *o);
virtual void Notify();
protected:
CSubject();
private:
CList<cobserver*, cobserver*=""> _observers;
};
---------------------------------------------------------------------
Now, I need to monitor a IO port. Then, I need to notify my CDocument whenever there is some IO activity. Hence, I create an CIOMonitor class which is single inheritance from CSubject.
// Please note that I remove most of the members. Only leave those which is related to this bug
class CIOMonitor : public CSubject
{
int GetInt() const;
}
I use Wizard in VC++ to create MDI project. Then, for the CCatchbugDoc (multiple inheritance from CDocument and CObserver). This is because CCatchbugDoc will be interested in the event happen in CIOMonitor
class CCatchbugDoc : public CDocument, public CObserver
{
public:
virtual void Update(CSubject *s) const;
};
Please note here is the root of evil
void CCatchbugDoc::Update(CSubject *s) const
{
/* Everything work fine with this unsafe casting */
/* But dynamic casting just prompt me a runtime error */
/**/
/* CIOMonitor *p = (CIOMonitor *)s; */
CIOMonitor *p = dynamic_cast<ciomonitor *="">(s);
if(p == NULL) {
AfxMessageBox("unknown error during dynamic cast");
return;
}
CString string;
string.Format("Nofity. CIOMonitor: %i", p->GetInt());
AfxMessageBox(string);
}
Here is my suspection
1. In VC++, CCatchbugDoc is created using dynamic creation. Initially, CCatchbugDoc is single inheritance from CDOcument. The following macro is added by VC++ wizard to enable dynamic creation:
IMPLEMENT_DYNCREATE(CCatchbugDoc, CDocument)
Now, I make CCatchbugDoc as multiple inheritance (CDOcument and CObserver). But I still use back the same
IMPLEMENT_DYNCREATE(CCatchbugDoc, CDocument)
Can this be the possible root cause of bug?
Thank you!
-cheok
|
|
|
|
|
In VC++ 6.0:
Go to Project->Settings...
Go to the C/C++ tab
Category = C++ Language
Check the box "Enable Run-Time Type Information (RTTI)
Set this to both Debug and Release
This makes your exe slightly bigger (not that much), but it allows you to query the types of the objects you're using, and use dynamic_cast.
Watch out for name clashes when using multiple inheritence. If you really need to use this, make sure the base classes do not have methods with the same name (and the base classes' base classes...).
Hope this helps
|
|
|
|
|
Thanks. That's really help me out. Just wondering why vc++ doesn't enable RTTI by default. I think they should give us compilation error when it encounter the user is trying to use RTTI feature by not enabling the RTTI flag.
|
|
|
|
|
Does anyone know of where I can find an example of getting/putting html source in an IE window using VC6. I think I need to use IPersistStream[Init] to be able to access the full source, but I don't really understand how. I have tried doing this with the body object, but the html was incomplete and I was unable to write changes back in because the body is read-only.
I have the rest of my BHO in place, but I am really stumped on to modify the html source code. Any help or directions would be great.
|
|
|
|
|
Hi, for easier portability(dont wanna use winmain to get rid of the console) i need to disable the console that usually pops up by default with the main() program entry function
I dont want any console to pop up. Anyone found a way to use the main function without getting a console right up your face once you run it, or how to kill it before it pops up.
I've looked everywhere for a solution but there seems to be no such available
|
|
|
|
|
How would disabling the console make the code more portable? Isn't the console just the way windows sets up stdout? I mean, if you write something like
#include <iostream>
int main{
std::cout<<"Hello World"<
|
|
|
|
|
Hello,
I need to download a web page and all the pictures that it has.any ideas how to do this?
|
|
|
|
|
|