|
pdc->IsPrinting() returns TRUE for real printing (printer dc) and for print preview (screen dc).
So it can't help me
|
|
|
|
|
The CPrintInfo class (passed to your view's OnPrint override) has a member m_bPreview that is set to TRUE when in Print Preview mode and FALSE when really printing. Additionally, you can override OnBeginPrintPreview and OnEndPrintPreview if you need to do more *advanced* setup for preview mode.
|
|
|
|
|
|
i have a CRichEditCtrl that needs to render to a metafile DC. i create the metafile DC using a screen DC as the "reference device". then i render the contents of the rich text ctrl into the metafile using FormatRange/DisplayBand. the code i have works fine, with one catch:
if the vertical position of the text in the rich text ctrl is larger than the vertical resolution of the screen (ie. if i tell the rich text control to draw text into the metafile DC at (100,1000) and the screen is only 1152x864), the text is clipped. the rich text control is obviously looking at the screen DC resolution and saying "hmm, i must be off the bottom of this DC. there's no need to draw those characters". but, in fact, it's not out of bounds on the metafile DC, since that is created without a bounding rect.
so, my question is... is there a way to create an off-screen DC with an arbitrary height ?
remember, this isn't a CDC+CBitmap issue, this is a metafile DC; i don't think creating and selecting a large bitmap into the metafile DC is going to do anything but waste resources (could be wrong).
-c
|
|
|
|
|
Hi folks,
does anyone know how to change the property page caption inside a Property sheet in MFC? the PropertyPage::SetWindowText does not work, neither changing LPCREATESTRUCT in PropertyPage::OnCreate. This caption is inherited by the property page dialog resource but there should be a way to change it at run-time...
Thanx a lot.
Regards,
andrea
|
|
|
|
|
I'm using this before adding the property page to the property sheet...
MyPP.m_psp.dwFlags |= PSP_USETITLE;
MyPP.m_psp.pszTitle = "The new title..."; Hope this helps
|
|
|
|
|
UAO IT WORKS!!!
Thanx a lot
Regards
andrea
|
|
|
|
|
Hi,
well in the constructor of your derived CPropertyPage try this code:
<br />
m_strCaption = m_aToolText.Anzeige(1);<br />
m_psp.pszTitle = m_strCaption;<br />
m_psp.dwFlags |= PSP_USETITLE;<br />
m_strCaption is a CString variable you must provide. The text to dbe displayed comes from elsewhere or you put in directly.
m_psp is variable/struct for the proprety sheet, and is already defined in the base class by the MFC.
I think you can change m_strCaption afterwards any way you want. But havn't tried this one out.
hope this helps
G. Steudtel
|
|
|
|
|
If I have a path as the next: "\\RESOURCE\\PathToRetrieve" in the Network domain "WORKGROUP", how can I split it in multiple directory for to create a tree path to reach it?
Excuse me for my English.
Thanks to all for help,
Margaria Ivano
|
|
|
|
|
Are you talking about the splitpath() function?
|
|
|
|
|
In Eplorer if you write a path in the toolbar and press ENTER the tree of the explorer go to the folder typed.
I have to do something like that.
Margaria Ivano
|
|
|
|
|
Ok, maybe SetCurrentDirectory() is what you're after.
|
|
|
|
|
here is my code:
In AppView.cpp :
----------------
void CTestApplicationView::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu Menu;
// Store popup point, and convert to client coordinates
// for the drawing functions.
Menu.LoadMenu( IDR_CONTEXTMENU );
CMenu* pPopup = Menu.GetSubMenu( 0 );
pPopup->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON,
point.x,
point.y,
this );
}
when i right click mouse i got an execution error on
TrackPopupMenu:
--------------
BOOL CMenu::TrackPopupMenu(UINT nFlags, int x, int y,
CWnd* pWnd, LPCRECT lpRect)
{
ASSERT(m_hMenu != NULL); <---------- PROBLEM HERE
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
HWND hWndOld = pThreadState->m_hTrackingWindow;
HMENU hMenuOld = pThreadState->m_hTrackingMenu;
pThreadState->m_hTrackingWindow = pWnd->GetSafeHwnd();
pThreadState->m_hTrackingMenu = m_hMenu;
BOOL bOK = ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0,
pThreadState->m_hTrackingWindow, lpRect);
pThreadState->m_hTrackingWindow = hWndOld;
pThreadState->m_hTrackingMenu = hMenuOld;
return bOK;
}
Any ideas, cause I really don't understand why ...
|
|
|
|
|
flybird wrote:
Menu.LoadMenu( IDR_CONTEXTMENU );
CMenu* pPopup = Menu.GetSubMenu( 0 );
Why are you not checking the return value of either of these functions?
|
|
|
|
|
Hi,
do the following things,
1. Declare CMenu Variable as a member variable
2. Load the menu, during initialization.
3. And, try now, it should work.
regards
~Hari~
|
|
|
|
|
Hi everyone.
I'm using the following class:
class Objekt
{
public:
CString get_name();
Objekt(const Objekt & temp);
Objekt();
Objekt(CString name);
virtual ~Objekt();
void add_obj_eventout(CString name, CString typ, CString objekt);
void add_obj_eventin(CString name, CString typ, CString objekt);
std::vector<EventIn> m_obj_eventinVector;
//EventIn/Out are some other classes with just 3 CString values
std::vector<EventOut> m_obj_eventoutVector;
private:
CString m_name;
};
Now there is another vector "std::vector<Objekt> m_objektVector;" that should build an "array" of Objekts. That vector is created in a MFC Dialog class (Instance: m_selekt);
What i'm trying to do now, is to access the m_objektVector from another (the first) MFC Dialog class that calls m_selekt via DoModal.
code:
//there have been added some objekts to m_objektVector
if(m_selekt.DoModal() == IDOK)
{
int x = m_selekt.m_objektVector.size();
for(int lv1=0;lv1<x;lv1++)
{
Objekt temp;
temp = m_selekt.m_objektVector[lv1];
CString soll = temp.get_name(); //works great
if(soll == auswahl) //not important
{
int eventins = temp.m_obj_eventinVector.size();
int eventouts = temp.m_obj_eventoutVector.size();
//Here is the problem eventins/outs stays 0 although there are entries for every Objekt!
/*........*/
Why can i get the correct value when calling get_name but trying to get something from the vectors is impossible?
Is it forbidden to create "multi vectors" or are all entries deleted when i'm creating the temp Objekt?
Maybe there is another possibility to send the data from one dlg to another?
Or is it just some stupid mistake (i'm quite new to visual c++)?
I hope you can understand the problem from my description. I'm trying to figure that out for two days now (tried CArray first - what was a complete desaster).
Thanks in advance for any answers/tips!!!
mfg david
|
|
|
|
|
Looks like you forgot to write a correctly working assignment operator for class Objekt.
|
|
|
|
|
Hi
I've subclassed a CEdit to CMyEdit.
I check in subclass CMyEdit OnChar() if the char. is allowed or not. When it is not allowed, i want to display a message in the label (IDC_LABEL) that i have made in the form. But the problem is, how can i change the windowtext of the label within the subclass? (sending message to parent?)
Anyone knows?
Greetings from another overworked student
Jens
|
|
|
|
|
Use:
LRESULT CMyEdit::NotifyParent(int msg)<br />
{<br />
NMHDR hdr;<br />
hdr.code = msg;<br />
hdr.hwndFrom = m_hWnd;<br />
hdr.idFrom = GetDlgCtrlID();<br />
<br />
CWnd *parent = GetParent();<br />
return pParent ? pParent->SendMessage(WM_NOTIFY, (WPARAM)0, (LPARAM)&hdr) : 0;<br />
}
Where msg is your notification code.
You may then handle the notification in the parent window's OnNotify .
Regards,
BB
|
|
|
|
|
I don't fully understand how this works
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CString strAllowed = "0123456789ABCDEFGHIJ";
if ( strAllowed.Find(nChar) != -1 )
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
} else
{
NMHDR hdr;
hdr.code = 9; // I would like to change to ERRCODE but that will not compile
hdr.hwndFrom = m_hWnd;
hdr.idFrom = GetDlgCtrlID();
CWnd *pParent = GetParent();
pParent->SendMessage(WM_NOTIFY, (WPARAM)0, (LPARAM)&hdr);
}
this i think sends the message to the parent window's OnNotify
BOOL CKeyXyDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
AfxMessageBox("onnotify");
return CDialog::OnNotify(wParam, lParam, pResult);
}
and i never see the messagebox
Any mistakes i've made?
Greetings
Jens
}
|
|
|
|
|
I've checked it and it should be working - you may need to Rebuild All.
In OnNotify , implement as follows:
<br />
NMHDR *hdr = (NMHDR*)lParam;<br />
if(hdr->idFrom == IDC_EDIT1 && hdr->code == EN_MYERROR)<br />
AfxMessageBox("This char is not allowed!");<br />
Regards,
BB
|
|
|
|
|
ok this works great!
Thanks alot Bartosz.
I'm trying to make something the user can type in like:
..-..-..-..-..-..
and when the user types in the characters the points have to replaced by the char. and cursor need to be repositioned too. Something like the 'IP control' actually but i've just started.
I've seen the '.' & the '-' in a editbox are so little. Can i make those characters bigger so it looks like the IP control?
(http://www.codeguru.com/editctrl/ip_addr_masked_edit.shtml)
Greetings
Jens
|
|
|
|
|
Another method
in ur derived class add a member function as SetParent(CDialog* pDlg)
and call this method after creating the control object
and with in the control class just send the Mesage to parent Window by using Send Message, U can pass the Char* buffer along with this send message and in ur parent class u just handle the Message properly
(just use ON_MESSAGE(MESS_ID, Routine() in MessageMap)
hope that u can
CodeTheDreams();
|
|
|
|
|
ok thank you .. you guys have helped me out very good
Greetings
Jens
|
|
|
|
|
hi,
How to hide my Application from the process list (TaskManager) in Win2000.
|
|
|
|