|
Theres a splashscreen.show(0 in oninitdialog, but no .hide(). yet it goes away...stepping takes me into CDialog::DoModal whereabout it vanishes.....I am puzzled. My other modal dlgs never disappear by themselves..yet in the code below it looks like it wil disappear by itself:????
int CDialog::DoModal()
{
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
if (m_lpszTemplateName != NULL)
{
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
if (lpDialogTemplate == NULL)
return -1;
HWND hWndParent = PreModal();
AfxUnhookWindowCreate();
BOOL bEnableParent = FALSE;
if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
{
::EnableWindow(hWndParent, FALSE);
bEnableParent = TRUE;
}
TRY
{
AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent);
DestroyWindow();
PostModal();
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
return m_nModalResult;
}
In this line:
DestroyWindow();<br /> it looks like it goes away by itself (any modal window)...
Appreciate your help,
ns
|
|
|
|
|
MSDN:
-----
CWnd::DestroyWindow
Destroys the Windows window attached to the CWnd object. The DestroyWindow member function sends appropriate messages to the window to deactivate it and remove the input focus. It also destroys the window’s menu, flushes the application queue, destroys outstanding timers, removes Clipboard ownership, and breaks the Clipboard-viewer chain if CWnd is at the top of the viewer chain. It sends WM_DESTROY and WM_NCDESTROY messages to the window. It does not destroy the CWnd object.
....
The DestroyWindow member function also destroys modeless dialog boxes created by CDialog::Create.
....
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
yes, but destroywindow is showing up in the DoModal() which makes me think that the dialog should vanish when DoModal is called, after first showing itself? MAy be I'm hopelessly confused ?(I am , I am )
Appreciate your help,
ns
|
|
|
|
|
The function of DoModal() is to display a window, loop until it wants to go away, and then destroy it. But, you should probably not be calling DoModal() for a splash screen *anyway*, since you're supposed to be doing other things while the splash screen is placating the user. Create() and ShowWindow() would be more likely, i think. The article should demonstrate it though.
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
Well, I was stepping through the code of their sample, and it took me into DoModal. However I see they use a CReate so its not modal....Thanks for the response
Appreciate your help,
ns
|
|
|
|
|
You can make the following, Project/Add To Project/Componentes And Controls
Then select Visal C++ Componentes and then Splash screen...
That will add you a Splash Screen component in yout project... It's a good sample to start
Cheers
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
When I try to open the same file 20 times (without closing), I get a runtime error. Is there a way to workaround that? Im working with COM, so is it a COM-specific limitation? Thanks
|
|
|
|
|
Regardless of why the runtime error is occurring, I believe you should rethink what you are doing. I can't think of a single reason to open the same file twenty times. Even if you have 20 threads doing I/O against the file, there's got to be a better approach than letting each thread open the file on its own.
Gary R. Wheeler
|
|
|
|
|
Please help me. This is driving me insane.
In the beginging of my myfile.cpp, I add this:
#include <Afxtempl.h>
Then I declared a global variable:
CArray < unsigned char, unsigned char > g_ubArrayReceived;
later, in a function, I called this:
if ( g_ubArrayReceived.IsEmpty() )
xxxxx;
I tried to compile, but VC++ 6.0 tell me that:
"error C2039: 'IsEmpty' : is not a member of 'CArray<unsigned char,unsigned char>'"
what???? what's wrong with me?
|
|
|
|
|
Cos he is right!
Check CArray::GetSize
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
well, that's a good alternative. I can use GetSize().
But on MSDN, it does have this:
Determines whether the array is empty.
BOOL IsEmpty( ) const;
Return Value
Nonzero if the array contains no elements; otherwise 0.
|
|
|
|
|
IsEmpty is not a member of CArray, but is for CList, CMap, CMapStringToOb CObList and CString!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
well, I think Microsoft should add this to its CArray class.
Thank you for your help!
|
|
|
|
|
It has been added in VC7.
Regards,
Bartosz Bien
|
|
|
|
|
Anyone seen any code or libs for automating Excel wihout using MFC?
I was hoping to use #import, but its a mess, and would rather not have to do everything that hard way as there is quite a bit to do.
I'm trying to avoid VB if I can.
|
|
|
|
|
Giles wrote:
Anyone seen any code or libs for automating Excel wihout using MFC?
Yes, see this MSDN article HOWTO: Automate Excel From C++ Without Using MFC or #import[^]
HTH
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
Thanks. I think I've seen this one. I was looking for something along the lines of #import to easy make use of smart pointers, but there are loads of clashes in the namespace (renaming seems to have no effect), and then a problem with reference counting.
|
|
|
|
|
Giles wrote:
I was hoping to use #import, but its a mess
Ah Ah! And you say smart pointers is a mess.
Better think twice. Smart pointers allow to focus on applogic, not on horrible COM details.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I wanted to use smart pointers, but there is a problem with reference counting.
Microsoft recommend using MFC, directly then lastly #import for Excel and other office apps, becuause they have done something funny.
Its not just a case of #import for e.g. ADO, where you only have to rename EOF. With Excel it seems there are over a hundred clashes in the namespace.
Have you had any luck with #import and Excel, if so I would be grateful for any tips.
|
|
|
|
|
Giles wrote:
Microsoft recommend using MFC, directly then lastly #import for Excel and other office apps, becuause they have done something funny.
There is no direct Office support in the MFC classes.
Giles wrote:
With Excel it seems there are over a hundred clashes in the namespace.
In the unlikely case you have this problem, you may just end your troubles by using the namespace rename attribute in #import.
Giles wrote:
Have you had any luck with #import and Excel, if so I would be grateful for any tips
Using smart pointers to drive Office apps is much like doing it with VB. Code is just easy to work with : in addition, you have intellisense!
The only tip about it, but it's a general tip about using smart pointers, is to avoid at all cost to use smart pointer instances in class members. Smart pointers are almost by design meant to be used as local proc variables.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
__Stephane Rodriguez__ wrote:
There is no direct Office support in the MFC classes.
I know, but using the class wizard to import the type library takes about 30 seconds, and makes life very easy.
__Stephane Rodriguez__ wrote:
In the unlikely case you have this problem, you may just end your troubles by using the namespace rename attribute in #import.
Yep, tried that, but it was having none of it.
__Stephane Rodriguez__ wrote:
Using smart pointers to drive Office apps is much like doing it with VB. Code is just easy to work with : in addition, you have intellisense!
Have you got a quick example? When I used namspace rename with #import it did not seem to work.
__Stephane Rodriguez__ wrote:
The only tip about it, but it's a general tip about using smart pointers, is to avoid at all cost to use smart pointer instances in class members. Smart pointers are almost by design meant to be used as local proc variables.
Never knew that. I've used parts of ADO happily as members of a class, well certain parts of it like the ADODB.Connection and Recordset, but not others, that are managed by a parent object e.g. Field, that could go out of scope if you moved to the next record.
As I said if you had a quick snippet of code with #import for Excel I would be really grateful.
Thanks,
Giles
|
|
|
|
|
Giles wrote:
using the class wizard to import the type library takes about 30 seconds, and makes life very easy.
This *is* #import, it has nothing to do with MFC. (remember #import is not C++ standard, only proprietary MS stuff).
Giles wrote:
As I said if you had a quick snippet of code with #import for Excel I would be really grateful
Always look up samples in the MSDEV CD. You've got ComExcel for instance. And it works like this :
#import "C:\Program Files\Microsoft Office\Office\excel8.olb" auto_search auto_rename
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
__Stephane Rodriguez__ wrote:
Always look up samples in the MSDEV CD. You've got ComExcel for instance. And it works like this :
#import "C:\Program Files\Microsoft Office\Office\excel8.olb" auto_search auto_rename
Thanks, this worked. I was still getting errors withe the rename_namspace() attribute.
|
|
|
|
|
is there a way to tell the date modified of a file on the web through an http request? i dont want to do ftp requests..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I am sure there is probably a way to get that information, I am not sure how to get it though.
However, if you want the date in order to know whether you should download the file or not, you can add the If-modified-since header item, and then the server will only send the file to you if it has been modified since the date that you sent. If the server does not send you back a file then the return status code will be 304.
If you are using MFC here is the sample code that you would use with the CTime object. If you would like sample code for regular C/C++ let me know.
CString sFileDate;
sFileDate.Format("If-modified-since: %s\r\n", ctime.FormatGmt("%a, %d %b %Y %H:%M:%S GMT"));
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|