|
Hi,
I am working in an application with docking window like Visual Studio 2005 interface. I do it with Visual Studio 2008 and MFC.
The left pane is a CTreeCtrl. I put items in it. When I click on an item, I want to display a form in the view portion of the application.
To do that, I have a member function called void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) to catch the event.
To display the form associated with the item clicked, I have to access the view class and after that the document class.
I access the view like that from the CViewTree::OnTvnSelchanged function:
CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
CCDSView* pView;
pView = (CCDSView*)pFrameWnd->GetActiveView();
I get memory leaks, but the program run anyway.
What I can't understand is that the program run under Vista 64 Home premium at home, but not run on an XP computer at office.
I compile it with Net Framework 2.0.
Does it has another way to access the view or document that does not crash my application ?
Thanks,
Claude
|
|
|
|
|
I am working with win32 application. I wanted to copy text using TextOut( ) in to temp DC (not original DC). then after BitBlt( ) copy temp DC in to original DC.
Here is my code please correct it.
case WM_PAINT:
{
HDC hdc;
hdc= CreateCompatibleDC(NULL);
TextOut( hdc,0,0, "Check Text", strlen( "Check Text" ) );
BitBlt(GetDC(hWnd), m_rect.left, m_rect.top, m_rect.right - m_rect.left, m_rect.bottom-m_rect.top,hdc, m_rect.left, m_rect.top, SRCCOPY);
}
|
|
|
|
|
From documentation [^]:
Remarks
A memory DC exists only in memory. When the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel high. Before an application can use a memory DC for drawing operations, it must select a bitmap of the correct width and height into the DC. To select a bitmap into a DC, use the CreateCompatibleBitmap function, specifying the height, width, and color organization required.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Modified code:
case WM_PAINT:
{
HDC hdc;
hdc= CreateCompatibleDC(NULL);
HBITMAP hBit = CreateCompatibleBitmap( hdc,m_rect.right- m_rect.left, m_rect.bottom -
m_rect.top );
SelectObject( hdc, hBit );
TextOut( hdc,0,0, "Check Text", strlen( "Check Text" ) );
BitBlt(GetDC(hWnd), m_rect.left, m_rect.top, m_rect.right - m_rect.left, m_rect.bottom-m_rect.top,hdc, m_rect.left, m_rect.top, SRCCOPY);
}
Still the code is not working. Thank You
|
|
|
|
|
zakkas2483 wrote: HBITMAP hBit = CreateCompatibleBitmap( hdc,m_rect.right- m_rect.left, m_rect.bottom -
m_rect.top );
I would use (see, for instance, ... documentation [^] ):
HDC hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
HBITMAP hBit = CreateCompatibleBitmap( hdcScreen,m_rect.right- m_rect.left, m_rect.bottom -
m_rect.top );
CreateCompatibleBitmap( hdcScreen, m_rect.right- m_rect.left, m_rect.bottom -
m_rect.top );
(I don't know if the
CreateCompatibleBitmap( NULL, m_rect.right- m_rect.left, m_rect.bottom -
m_rect.top );
'shortcut' would work).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have inserted a combo-box control in my project.
In that control vertical scroll bar is present.
I want horizontal scroll bar also.
how to attach horizontal scroll bar to control
thanks
|
|
|
|
|
saksp wrote: I have inserted a combo-box control in my project.
In that control vertical scroll bar is present.
I want horizontal scroll bar also.
how to attach horizontal scroll bar to control
First edit .rc file to add WS_HSCROLL to combo box style codes since dialog does not support this. Then use this function, I've for demo purpose given 600, you need to use GetTextExtent function to get the real extent, look up MSDN for SetHorizontalExtent sample code...
void CDialoTestDlg::AddHScroll()
{
CComboBox* pCmb = (CComboBox*)GetDlgItem(IDC_COMBO_HORZ_EXTENT);
ASSERT( pCmb );
pCmb->SendMessage( CB_SETHORIZONTALEXTENT, 600, 0 );
}
|
|
|
|
|
Hi All,
I have an application in Visual Studio 2003. As a part of the patch updates, I adding a new component built in VS-2005 (which is a dll), to the existing components (built in VS-2003). From my unit testing the new module (dll) seems to work fine and is functioning well i.e. my old application is able to load the dll library dynamically. But i do remember of few C-run time compatibility issues from the past and I am not able to recollect the same.
Could you guys throw some light onto this and let me know any special pre-requisites that i should take care of ?
Thanks for your time.
Sunil
|
|
|
|
|
Hi,
I try to use "Win32_Tpm" to manage TPM in C++, Now i can get some info from TPM by "ExecQuery", but i want to use the class method such as "IsEnabled" by "ExecMethod", it returns error "-2147217361", it maybe means "InvalidMethodParameters "(found in net http://mono.ms.mff.cuni.cz/projects/mono/diffs/showdiff.php?old=2007-10-03&new=2007-10-04&diffIndex=15&bench=
code :
BSTR ClassName = SysAllocString(L"Win32_Tpm");
BSTR MethodName= SysAllocString(L"IsEnabled");
BSTR argname = SysAllocString(L"Request");
hres = pSvc->GetObject(L"Win32_Tpm", 0, NULL, &pclsObj, NULL);
hres = pclsObj->GetMethod(_bstr_t(L"SetPhysicalPresenceRequest"),0, &pInParamsDefinition, NULL);
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
varCommand.vt = VT_BSTR;
varCommand.bstrVal = L"14";
hres = pClassInstance->Put(argname, 0,&varCommand, 0);
hres = pSvc->ExecMethod(ClassName,_bstr_t(L"SetPhysicalPresenceRequest"),0,NULL,pClassInstance,&pTmpclsObj,NULL); ----- return "-2147217361" here
// isEnabled
hres = pSvc->ExecMethod(ClassName,MethodName,0,NULL,NULL,&pTmpclsObj,NULL); ----- return "-2147217361" here
Can somebody help me?
Thank a lot!
Stanley Hwang
|
|
|
|
|
I need to find out the width and height (in pixel/ in any logical unit) of a string.
I am using GetTextExtentPoint32() API to calculate the string size. But it is observed that the GetTextExtentPoint32() is giving me the different size , if execute my application on different language OS. After some analysis it is observed that font size and font face value is affecting the size of a string, so i have set the font face and font size to the DC.But still due to different CHARSET value available on different language OS i am getting different size of a string. Please let me know how to handle this issue, so that i can get same value of a string (string from any language) for different language OS.
I wrote the method as below:
LPSIZE lpSize = new SIZE () ;
void MyAPI( CString szLangStr , lpSize )
{
....
}
So the expected out put the width and height of szLangStr and which should be same for all the language OS.
|
|
|
|
|
Cannot you just be prepared to deal with different string sizes?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
pandit84 wrote: Please let me know how to handle this issue, so that i can get same value of a string (string from any language) for different language OS.
I really doubt if this is possible. There will be a lot of variation between fonts, and user preferences may come into it as well.
As noted in the previous reply, you're much better designing your app to handle different sizes of string.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Did you not just ask this same question 9 minutes ago?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Noooooo - he's asking about string width AND height now, not just width
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Fair comment.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi!
I'm trying to run MFC example from VS2005, and I get a lot of errors
Error 1 error C2039: 'GetInt' : is not a member of 'CMFC001App'
Error 2 error C3861: 'InitUserToolbars': identifier not found
Error 3 error C3861: 'DockPane': identifier not found
there are just a few first (of 50!), and I cant figure this out, because my simpler C++ programs run just fine.
thank you
|
|
|
|
|
Take a look at the code you posted
thanks
|
|
|
|
|
Where's your header file?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
there are in the same folder as cpp files
C:\Users\XXX\Documents\Visual Studio 2008\Projects\MFC 001\MFC 001
if that's what you asked
|
|
|
|
|
No did you set it on your file(c++)?
#include "yourfile.h"
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
Hello,
After creating a child window I change the title of the window by SetWindowText() but as soon as I change the foucs to some other child window the title of the earlier window changes to the name of the program which would have appeared if I had not chaged te title of the window.
How should I maintain the canged title even if the focus is changed.
Prithaa
|
|
|
|
|
There is an undocumented function called OnUpdateFrameTitle in the CFrameWnd class.
Override it in your main frame class and set the title from withing the overload.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
hello,
I have created a indow with the command CreateNewChild().Can alter the size of the window immediately before displayed on the screen.
Pritaa
|
|
|
|
|