|
How can I resize a view to be as big as a particular frame-window?
I have an app with multiple views in one frame-window. Off course, only one can be active. When I resize the window, all in-active views need to be resized as well. It does not happen automatically. How do I do that? I have pointer to all of them.
Thank You for your help,
XP
|
|
|
|
|
It seems to me that you could handle the WM_SIZE message in the frame class to capture when the window gets a new size. From there, you can resize the windows as you like by using MoveWindow on any views you wish to move or resize.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
This works, but the view gets disconnected from the frame.
What I mean is, the view gets resized to the size of the frame, but it draws itself over the status bar of the frame. When I resize I can make parts of the status bar appear. The view seems detached form the frame although I called SetActiveView().
Any thought?
Thank you.
|
|
|
|
|
I'm working on an app that can change languages at run-time. It can be run in English, or Chinese (and many others, but for simplicity's sake I'll focus on those.)
Anyhow, this app works fine in English on an English system, and fine in English or Chinese on a Chinese system. Problem results when running in Chinese on an English system. The fonts are there, and IE can display them fine.
The problem is that most dialog controls (e.g., CStatic, CButton) will *not* display the Chinese text right, even if I select a Chinese-encoded font into the control. What I get are what appear to be the DBCS strings in ASCII or something. In spite of this, a CEdit with the same font in the same dialog will work just fine!
One more thing - if I make my own control derived from, say, CStatic, and override OnPaint to display text myself, it works.
Anybody know what gives? Will I have to override the default controls that don't happen to work (CStatic, CButton) with my own controls? Is this a problem with MFC, or the underlying Windows controls?
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I worked with cirillycs Idiomas, Hebrew and Arabic with a application that changed from English to Portugesse or Spanish or hebrewm, or russia, etc.
For that I needed to work in a Hebrew operating system, The classes didn't work fine with these Idioms, I needed to work all in unicode, and when you tray to make a CWnd::SetWindoText, CString don't supports those characters. I needed to create every control with the Create function, etc....
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
Well, what seems odd, is that, let's say I derive a control from CStatic (or make a custom control.) In my OnPaint handler, I have the code below, and it works fine! So it's not a problem with CString or Set/GetWindowText, or TextOut. It does make me wonder what a CStatic (or Windows static) control could possibly be doing that is messing this up??
<br />
CPaintDC dc(this);<br />
<br />
CString str;<br />
CRect rect;<br />
<br />
GetWindowText(str);<br />
GetWindowRect(&rect);<br />
<br />
CSize textSize = dc.GetTextExtent(str);<br />
<br />
int x, y;<br />
x = rect.Width() / 2 - textSize.cx / 2;<br />
y = rect.Height() / 2 - textSize.cy / 2;<br />
<br />
dc.SetBkMode(TRANSPARENT);<br />
dc.SelectObject((CFont *)GetFont());<br />
dc.TextOut(x, y, str);<br />
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
Hi...
just few simple questions:
1. how do u call an application in your VC++ project? e.g. I want to call real player.exe in my project.. what's the command?
2. What's the command to copy one file? e.g. I wanna copy pic.bmp to c:/image/pic.bmp
3. How do I know what's my current working directory?
Thanks a LOT....
|
|
|
|
|
|
1- CreateProcess();
2- CopyFile()
3- GetCurrentDirectory();
Cheers
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
MSDN has all these functions, although these types of functions are typically Windows API, and not wrapped in any way by MFC.
For running a process, there are a couple others:
1. ShellExecute: it is nice if you have a program's date (e.g., a RealPlayer file) and want the system to find the app that handles it.
2. CreateProcess: if you want full control over creation, but it is probably the most complicated of the ways to run a program.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I have a property sheet, and one property page (CFirstPage). m_showInfo is a bool, and m_ctrShowInfo is the DDX control for the checkbox. I want to initialise the property page with the current settings.
In my implementation file;
CFirstPage::CFirstPage() : CPropertyPage(CFirstPage::IDD)
{
if(m_showInfo)
m_ctrShowInfo.SetCheck(1);
else
m_ctrShowInfo.SetCheck(0);
}
If i use SetState() instead, everything goes well. However, SetCheck() crashes at CButton::SetCheck. Any ideas why?
---
"Transmit in all known frequencies and in all known langauges, including Welsh."
|
|
|
|
|
because m_ctrShowInfo isn't a "window" yet, and SetCheck is sending a window message.
try setting this in your InitDialog
-c
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Argh! My head is hurting. All this MFC i've been doing has reduced my potential lifespan. I actually figured it out whilst watching neighbours, but thanks anyway.
---
"Transmit in all known frequencies and in all known langauges, including Welsh."
|
|
|
|
|
Look into the declaration of m_ctrShowInfo Is a CButton or another thing?
Best Regards!!!
Carlos Antollini.
Today is Fridad!!! for All!!!
|
|
|
|
|
Look into the declaration of m_ctrShowInfo Is a CButton or another thing?
But the problem is that you are in the contructor of your class, and the control have not HWND yet.....
Best Regards!!!
Carlos Antollini.
Today is Fridad!!! for All!!!
|
|
|
|
|
Try to do that in the InitDialog. In that instance the Hwnd exists
Best Regards!!!
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
The app that I am making has this sucken in look where all the controls are at. I tried changing the windows style in this function, but that didn't work. I am trying to get rid of the sunken in look and make the whole area where the controls are located raised up with the rest of the app.
I sure appreciate any help.
|
|
|
|
|
Two questions:
(1) Is your app MDI or SDI?
(2) What kind of view you are using to display controls?
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
The app is SDI and I am using IDD_MFC_FORM.
|
|
|
|
|
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPEDWINDOW;
return TRUE;
}
I thought by adding the OVERLAPPEDWINDOW would fix this problem, but it does not seem to do it.
|
|
|
|
|
No, I guess WS_OVERLAPPEDWINDOW style bit is already set for MFC frame windows before ::PreCreateWindows() gets the hit, so this won't help.
I think I have a solution, I'll come back soon.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Here is a quick solution for you.
Overide CMainFrame's ::ReCalcLayout() and add this
void CMainFrame::RecalcLayout(BOOL bNotify)
{
CFrameWnd::RecalcLayout(bNotify);
CView* pView = GetActiveView();
if(pView && pView->GetSafeHwnd())
{
CRect rect;
pView->GetWindowRect(rect);
ScreenToClient(rect);
rect.InflateRect(2, 2);
pView->MoveWindow(rect);
}
}
This would take out the client edges nicely provided that you don't have any controlbars docked on the frame.
This is a quick and dirty solution. There could be other ways of doing this. I'll try to find other solution later.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Nice!!! This worked like a charm! Thank you for taking the time on this problem!
|
|
|
|
|
Here's part of my code:
void CValidateurlDlg::OnButton1()
{
...
for(int i=0;i<m_purllist->GetCount();i++)
{
...
ValUrlMgr.Validate(this, url);
}
}
void CValidateUrlMgr::Validate(CWnd* pWnd, Url UrlInfo)
{
THREADPARMS* ptp = new THREADPARMS;
ptp->UrlInfo = UrlInfo;
ptp->pWnd = pWnd;
ptp->pCriticalSection = &m_cs;
ptp->pEvent = &m_event;
CWinThread* pThread = AfxBeginThread (ThreadFunc, ptp,
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
::DuplicateHandle (GetCurrentProcess (),
pThread->m_hThread, GetCurrentProcess (), &m_hThread,
0, FALSE, DUPLICATE_SAME_ACCESS);
pThread->ResumeThread ();
}
//////////////////////////
UINT ThreadFunc(LPVOID pParam)
{
...
THREADPARMS* ptp = (THREADPARMS*) pParam;
Url UrlInfo = ptp->UrlInfo;
CCriticalSection* pCriticalSection = ptp->pCriticalSection;
CEvent* pKillEvent = ptp->pEvent;
CWnd* pWnd = ptp->pWnd;
delete ptp;
pCriticalSection->Lock ();
Doing some stuff....
pCriticalSection->Unlock ();
return 0;
}
If I dont comment the Lock() / Unlock() lines, I get an Unhandled error message. Not using them = works great! What's the use of critical sections then???
thanks!
|
|
|
|
|
This may have nothing to do with your problem, but have you taken into account that CCriticalSection s by default are locked right after construction? Maybe you'll have to add m_cs.Unlock() somewhere on the ctor for CValidateUrlMgr . If this is already known to you, excuse my guessing around.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|