|
Dear Carlos,
Replaced the below line
sa=var; // <=Here
with sa = COleSafeArray(var);
the same assert error occur again. Look at the below codes for ref.
COleSafeArray::COleSafeArray(const VARIANT& varSrc)
{
AfxSafeArrayInit(this);
*this = varSrc; // assert error here!!! (it invoke below codes)
m_dwDims = GetDim();
m_dwElementSize = GetElemSize();
}
COleSafeArray& COleSafeArray::operator=(const VARIANT& varSrc)
{
ASSERT(varSrc.vt & VT_ARRAY); // The real assert err occur here!!
AfxCheckError(::VariantCopy(this, (LPVARIANT)&varSrc));
return *this;
}
Any suggestion? Anyway, thanks for your quick response!
Wayne
05 Sep 2001
|
|
|
|
|
Dear Carlos!
Try your method, same assert error occured!
Take a look at below codes for ref.
COleSafeArray& COleSafeArray::operator=(const VARIANT& varSrc)
{
ASSERT(varSrc.vt & VT_ARRAY); // Assert err occured here!!!!
AfxCheckError(::VariantCopy(this, (LPVARIANT)&varSrc));
return *this;
}
Anyway, thanks for your quick response! Any other suggestion?
Wayne
05 Sep 2001
|
|
|
|
|
I'm learning MFC's and I've the problem. I want to write a new line character to a CEdit control but I can't!
Here's the code:
CString myString;
myString = "some string \n more";
myEditCtrl.SetWindowText(myString);
and I get displayed: some string <strange char=""> more
I've initializated the control with ES_MULTILINE, but it still doesn't work.
Please I need help !!!!!!!!!!!
|
|
|
|
|
|
thanks for your quick answer!
|
|
|
|
|
> CString myString;
> myString = "some string \n more";
CEdit controls require CR-LF for newlines. Change your string to:
CString myString;
myString = "some string \r\n more";
and it will work.
HTH
Parish
while (!asleep)
code();
|
|
|
|
|
For those of you who haven't read it already I recently posted an article with some code for a new owner drawn button (CButtonSSL). Thanks to Paolo and Jerzy's work (COddButton) I included the correct handling of the default button state for this button class.
Unfortunately it has a problem with radio buttons (see the Known Problems section).
The solution that Paolo has suggested (get the control type in PreSubClassWindow) would solve the problem, but requires the owner draw style to not be set initially.
My question is what would you prefer? A class that works correctly for buttons, check boxes and radio buttons, but at the expense of remembering not to set the owner draw style (something that I always find myself doing for a button I know is owner drawn), or a class that works for buttons and check boxes?
Your feedback would be much appreciated. And thanks for the votes
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Whenever I do anything like this I set the style how it needs to be in the constructor, so it doesn't matter what it get set to in the dialog editor by the user.
I don't suppose your article doesn't use MFC ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You can not set the style in the contructor because you need a window. PreSubclassWindow is the place...
|
|
|
|
|
Thanks - I knew I wasn't being completely accurate but couldn't remember the function I set it in. It wasn't PreSubclassWindow, but I'm sure it has the same effect.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
The problem is not of setting the owner draw style (which is enforced at the end of PreSubclasWindow), it is finding out what type of control it is (checkbox, button or radio button).
If the owner draw style is set in the dialog editor then because button styles are not mutually exclusive you can't tell what type of control it was.
P.S. Unfortunately (for you) it does use MFC. Feel free to do a non-MFC conversion
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
I have created an VC++ activex and I would add a graphic in my project. I try to add the MSChart control in my project but, when i execute the roject, i can't display it.
Please Help me!!!!!!
|
|
|
|
|
I have a main Dialog application wich instantiate a new Dialog Like this...
m_pThread= AfxBeginThread(RUNTIME_CLASS(CMultiThread));
CMultiThread is a CWinThread .
This one takes care of Showing the new dialog box on the screen
BOOL CMultiThread::InitInstance()
{
CPostDialog Dlg;
//CoInitializeEx(0, COINIT_APARTMENTTHREADED);
CoInitializeEx(0, COINIT_MULTITHREADED);
m_pMainWnd= &Dlg;
Dlg.DoModal();
return TRUE;
}
Everythings is working fine.
On the ExitInstance() of this thread i want to post a message to the caller (Main Dialog) that CPostDialog is now over.
The problem is no matter what i try i can't get the HWND of
the caller.
I think that i should get the HWND in the InitInstance
What i did so far in the main dialog is to declare a public variable like this
HWND m_LocalWnd;
Then on the OnInitDialog() of the main dialog
m_LocalWnd =m_hWnd;
Then i change the InitInstance of my CWinThread like this
BOOL CMultiThread::InitInstance()
{
CMessageTestDlg pApp;
m_HwndSource = pApp.m_hWnd;
CPostDialog Dlg;
//CoInitializeEx(0, COINIT_APARTMENTTHREADED);
CoInitializeEx(0, COINIT_MULTITHREADED);
m_pMainWnd= &Dlg;
Dlg.DoModal();
return TRUE;
}
CMessageTestDlg is already running and i should be able
to get the HWND..
but it always return 0
What is it wrong.
Yves Lessard
|
|
|
|
|
The line
CMessageTestDlg pApp;
<\PRE>
makes a new instance of the CMessageTestDlg class - it does not give you access to the global CWinApp derivative in your main thread. Use AfxGetApp() instead (I'm pretty sure it works across threads, but you may check to be absolutely sure). You can, however, not use AfxGetMainWnd() as this is thread-specific.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
&/¤#(#)(/!!=?¤(¤%&!!!!!!
I thought I finally got those tags right! Instead I just made my reply like 4 monitors wide! What did I do wrong? Sorry about this.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I want to display the minimize box only and not the close or maximize buttons. Is there any way to do this?
Alternatively is there any way to add a button to the title bar and use it instead.
Thanx...
|
|
|
|
|
To disabled the maximize button do this in PreCreateWindow()
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style&=~WS_MAXIMIZEBOX;
return TRUE;
}
To disable system menu do this:
cs.style&=~WS_SYSMENU;
Jerzy
|
|
|
|
|
This only grays out the MAX box...
> cs.style&=~WS_MAXIMIZEBOX;
This disables the entire menu...
> cs.style&=~WS_SYSMENU;
What I need is remove the maximize and close buttons, not just gray them out. I only want the minimize button to appear.
But thanx anyway...
|
|
|
|
|
You can draw it yourself (e.g. winamp)
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject "
|
|
|
|
|
Any source code to demonstrate this ?
Thanx..
|
|
|
|
|
Is it the main app window?
How bout:
HMENU hmenu = GetSystemMenu ( hwnd, FALSE );
DeleteMenu ( hmenu, SC_CLOSE, MF_BYCOMMAND );
later
Oops - just realized that you want to get rid of the buttons entirely - this won't do it. You may have to take over WM_NCPAINT handling...
|
|
|
|
|
I am writing a Win32 program (no MFC), and I need to display a context menu.
Every thing works fine, except that the size of the menu is wrong.
It looks like the vertical size of the menu is spot on, however the horizontal size is as small as you can get thus not displaying the menu items.
Is there a function I need to call before calling TrackPopupMenu?
Thankyou ,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
You need to get the submenu:
CMenu * m_Popup;
CMenu m_SysTrayMenu
<BR>
m_SysTrayMenu.LoadMenu(IDR_MENU1);
<BR>
POINT CursorPos;
GetCursorPos(& CursorPos);
m_Popup=m_SysTrayMenu.GetSubMenu(0);
m_Popup->TrackPopupMenu(TPM_RIGHTALIGN,CursorPos.x,CursorPos.y,this,NULL);
|
|
|
|
|
But I can't do it this way because I am not using MFC...
Thanks anyway though ,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
I believe the function you want is called GetSubMenu(HMENU menu, int Pos)
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|