|
Hello!
That's easy!
1. Overlapped the ActivateFrame method of the CChildFrame.
2. Add bold string to this method:
void CChildFrame::ActivateFrame(int nCmdShow)
{
nCmdShow = SW_SHOWMAXIMIZED;
CMDIChildWnd::ActivateFrame(nCmdShow);
}
That's all, Bye
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
|
CalcWindowRect for CFrameWnd
Hi, in MFC the class CFrameWnd do not have it's own implementation
of the virtual function CalcWindowRect. I need a CalcWindowRect which
given a certain-sized client rectangle, adds the heights and widths
of all the toolbars, menus, window frames, scrollbars and status bars.
Did I forget something? Have anyone already written one for lazy me
I could use?
Otherwise, I guess I have to do it myself. Anyone knows how to calculate
the height of the status bar? The following code do not work,
nStatusbarHeight is zero afterwards, however the status bar works fine,
I can update the text of the pane with index ID_INDICATOR_CAPS for example.
CRect rect;
m_wndStatusBar.GetItemRect(ID_INDICATOR_CAPS, rect);
int nStatusbarHeight = rect.Height();
Thanks for all input, Patric
|
|
|
|
|
From your description, it sounds like you're looking for the size of the entire window, including nonclient areas. Use GetWindowRect() for that.
--Mike--
My really out-of-date homepage
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I am interested in the size of the entire window, however not it's
current size. I want the application to set its own size. I know
the view's size. Now I want to set the size of my frame object, CMainFrm, so it is perfectly fits the view, with toolbars and everything. Therefore I need a CalcWindowRect for CFrameWnd.
/Patric
|
|
|
|
|
Maybe I'm totally missing your point, but I use the following snippet of code to adjust the frame's size to that of a CFormView (in CYourView::OnInitialUpdate )
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE); Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OK, this was what I wanted, I looked into
CScrollView::ResizeParentToFit and ripped
some code, simplifyied it and put in my
view's OnInitialUpdate. It was easier than
implementing a CalcWindowRect in the mainframe
class.
/Patric
// Remove scroll bars.
SetScrollSizes(MM_TEXT, CSize(0, 0));
GetParentFrame()->RecalcLayout();
// Get the view's current size.
CRect rectViewCurrent;
GetClientRect(rectViewCurrent);
// Get the frame's current size.
CRect rectFrame;
GetParentFrame()->GetWindowRect(rectFrame);
// Calculate the needed space for toolbars, caption, statusbars and borders by
// subtracting the view's size from the frame's. Then calculate the desired size
// for the frame by adding rectsize to it.
CSize size;
size.cx = rectSize.Width() + rectFrame.Width() - rectViewCurrent.Width();
size.cy = rectSize.Height() + rectFrame.Height() - rectViewCurrent.Height();
// Finally, lets change the size of the frame to the one we want.
GetParentFrame()->SetWindowPos(NULL, 0, 0, size.cx, size.cy,
|
|
|
|
|
I'm trying to automate powerpoint(with a type library) so i can open a file in powerpoint from my app but it wont work, here's what i have:
Presentations pf;
CString file;
file = "C:\\My Documents\\Afwezigheden.ppt";
pf.Open(file,FALSE,TRUE,TRUE);
Can anyone tell me why it wont work?
(BTW everything else works, i can start powerpoint)
Kuniva
|
|
|
|
|
Hi,
How can i change English Date to Hijri Calender(Date) ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
There are various algorithms that do this
I came across this one, It may help you
http://www.codearchive.com/newcode/comments/comments.cgi?section=c&codenumber=1612
|
|
|
|
|
Thanks Mr.Rashid,
Your help was useful
With Best Regards
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
When using Win32 ChooseColor() function, how can I read currently selected color without leaving the color dialog (i.e. before ChooseColor function exits) ?
|
|
|
|
|
I have an activeX control that I have tested and signed - however I have discovered
that I can download the control from a web page that is on a different site to the control (.cab)
Is there a way of marking the control so that it cannot be 'borrowed' by another site ?
Holy Handgrenade of Antioch instructions
|
|
|
|
|
there's some licensing you can do - for example, the MSHFlexGrid (in Visual Studio etc) is a licensed control - there is a special procedure that must be gone through to use it on a machine that does not have VB or Visual Studio installed. I don't know how to license a control, but I do have experience with this particular control and the hoops we had to do to get it to work. (on a pc that had not had the licensing procedure run, it displays as a blank box)
|
|
|
|
|
thanks - I did look at licensing but I couldn't see how it would stop anyone from using the control x-domains - I eventually implemented something via IObjectWithSite - to get the URL that the control was working under and then check to see if the url domain was one I allow access to
Holy Handgrenade of Antioch instructions
|
|
|
|
|
Hi.
My program needs a block of binary data to work. I do not want this binary data in a separate file because it is a) unchanging and b) i want minimal dependancies.
I've created a custom resource in resource editor and put my binary data in there.
I want to get a (BYTE *) pointer to this data at run time. The only method i've found of doing that up to now is this:
BYTE *p_SREData;
HGLOBAL hGlobal; HRSRC hRSrc;
hRSrc=FindResource(NULL, MAKEINTRESOURCE(IDR_DATA1),RT_RCDATA);
hGlobal=LoadResource(NULL, hRSrc);
p_SREData=(BYTE *) LockResource(hGlobal);
Whilst this works, surely there's a better, simpler way of getting the data?
And MSDN for LockResource states that the system frees allocated memory upon program termination, but you can free the memory manually when you no longer need it by calling one of the functions. But it's not obvious which function to use for a custom binary resource. Any ideas?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Actually there is a faster way to do this. If you define your custom resource as for example
a "BINARY" data (Insert Resource->Custom (button) ->"BINARY" without quotes).
I always defined custom resource as binary anyway but give it the name you want...
Fastest way to get the data in my opinion is this:
// LPCTSTR lpszName = MAKEINTRESOURCE( idr_your_resource_id );
// LPCTSTR lpszType = _T("BINARY");
// HINSTANCE hRes = AfxGetResourceHandle();
BYTE* GetResourceData(LPCTSTR lpszName, LPCTSTR lpszType, HINSTANCE hRes)
{
HRSRC res = ::FindResource(hRes, lpszName, lpszType);
ASSERT( res != NULL);
BYTE* pBytes = (BYTE*) LockResource(LoadResource(hRes, res ));
ASSERT( pBytes != NULL);
return pBytes;
}
|
|
|
|
|
Hello everybody!
I have a little problem, help me please!
1. I'm create the listbox with multi-column style
2. I'm set the Width of ListBox (SetColumnWidth )
How can I add string to the second column, third column and etc?
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
You should use:
BOOL SetItem( int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, int nImage, UINT nState, UINT nStateMask, LPARAM lParam );
The nItem is the line and the nSubItem is the column:
SetItem(102,2,0,"Second Colum",0,0,0,0);
|
|
|
|
|
But SetItem method is a member of the CListCtrl class and not member CListBox.
I want made multi-column from CListBox!
Sonork ID 100.10002:Yaumen
|
|
|
|
|
You can't! use CListCtrl. CListBox has less features than CListCtrl but
a CListCtrl is a bit harder to use.
|
|
|
|
|
Thank you for all!
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Hi -
VC6 NT4 and Win98
I'm having a problem where TrackPopupMenu() fails and ERR is 0. I make the call inside a worker thread. Why does it fail there with no error? I read somewhere that TrackPopupMenu has its own message pump. Is this true?
Here's some code:
//
// this method works.
// TrackPopupMenu returns 1 and the menu is displayed.
//
void CTestMenusDlg::OnButton1()
{
CMenu *pMenu = new CMenu();
VERIFY(pMenu->CreatePopupMenu());
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32001, "Test1"));
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32002, "Test2"));
BOOL bOK = ::TrackPopupMenu(pMenu->m_hMenu,
TPM_LEFTALIGN |TPM_RIGHTBUTTON,
300, 300, 0, this->m_hWnd, NULL);
}
//
// this method will start a thread
//
void CTestMenusDlg::OnButton2()
{
CWinThread *pThread = AfxBeginThread(
PipeThread, this, 0,THREAD_PRIORITY_NORMAL,0,NULL);
}
//
// Runs same code as button1.
// TrackPopupMenu returns 0 and ERR is 0
//
UINT PipeThread(LPVOID lpvParams)
{
ASSERT( NULL != lpvParams );
CTestMenusDlg *pDlg = reinterpret_cast<CTestMenusDlg *>( lpvParams );
CMenu *pMenu = new CMenu();
VERIFY(pMenu->CreatePopupMenu());
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32001, "Test1"));
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32002, "Test2"));
BOOL bOK = ::TrackPopupMenu(pMenu->m_hMenu,
TPM_LEFTALIGN | TPM_RIGHTBUTTON,
300, 300, 0, pDlg->m_hWnd, NULL);
DWORD dwErr = ::GetLastError();
return 0;
}
|
|
|
|
|
I have a question:
Why you want to create a popup menu from a worker thread?
|
|
|
|
|
>> Why you want to create a popup menu from a worker thread?
Actually my real code does the opposite of my example. A worker thread gets sent a menu hierarchy via CORBA, creates a bunch of HMENUs and stores them in a table. Later on, when an item in a view is right-clicked, I look up the appropriate HMENU and create a popup.
When I started to debug this thing, I was sure that it was a threading issue and I thought that I couldn't share HMENUs across threads. I wrote a TestMenu app to check this theory out and I somehow flipped it so that the popups were being created inside the worker thread.
I've solved my problem though - a coding error in the worker thread was creating empty menus. Good HMENUs, but just no items. Still, in this instance and in my example code, when TrackPopupMenu was failing, it returns 0 and GetLastError is 0.
If TrackPopupMenu has its own message pump (as someone wrote in another post) and I pass a valid hWnd to TrackPopupMenu, why would it matter though if I called it from a non-UI (worker) thread?
thanks
|
|
|
|
|