|
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!
|
|
|
|
|
how would i use this if-modified-since when requesting the file? currently i am just giving the location of the file on the web, and where i want to save it.. here is what i have, thanks!
hr = URLDownloadToFile( NULL,
sURL,
sFile,
0,
&callback
);
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hello...
I need to show an editcontrol and a combobox over a listcontrol depending of the kind of edition that is allowed in the field that I want to modify...
(i.e: if I'm editing a field that can only have 3 possible values, the combo have to be shown, but if the field can get any value, then I need to show the editbox)
In order to do this I'm using an article readen in codeproject
http://www.codeproject.com/listctrl/editing_subitems_in_listcontrol.asp[^]
and my problem is that when I do the same that is explained in this article, I don't understand why the editcontrol and the combobox disappear...
I don't want the combo box to disappear, the editbox is OK...
any idea?
NOTE:
I've tried to set it topmost (using SetWindowPos), but it's the same...
As always thank you in advance...
|
|
|
|
|
My guess would be that you need to change the tab order of the edit/combo controls compared to the list control. They either have to be before or after it in the tab order. I forget which.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
I hate when the solution is so simple...
I've invalidated the combobox...
but thank you for your interest!
|
|
|
|
|
OK guys...I'm trying to display an AVI file on my dialog with a transparent background and I'm not having any luck,
I made an AVI file with a white background on each clip. I have an animation control on my dialog and I have both transparent properties set. When I go to play the AVI, I still see the white background.
Here is the function to create the control:
HWND CreateAnimationCtrl(HWND hwndDlg, int nIDCtl)
{
HWND hwndAnim = NULL;
RECT rc;
POINT pt;
hwndAnim = Animate_Create(hwndDlg, IDC_ANIMATE, WS_CHILD, ghInst);
Animate_Open(hwndAnim, MAKEINTRESOURCE(IDR_AVI));
ShowWindow(hwndAnim, SW_SHOW);
return hwndAnim;
}
Here is what I call in the WM_INITDIALOG routine:
hAnim = CreateAnimationCtrl(hDlg, IDC_ANIMATE);
Animate_Play(hAnim, 0, -1, -1);
Do I have to do something special to the AVI as well?
Any help would be greatly appreciated.
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Have you added the ACS_TRANSPARENT (2) flag value in the windows style value of the video window?
ACS_TRANSPARENT:
Allows you to match an animation's background color to that of the underlying window, creating a "transparent" background. The control will send a WM_CTLCOLORSTATIC message to its parent. Use SetBkColor to set the background color for the device context to an appropriate value. The control interprets the upper-left pixel of the first frame as the animation's default background color. It will remap all pixels with that color to the value you supplied in response to WM_CTLCOLORSTATIC.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
HANDLE CreateFileMapping(
HANDLE hFile,
LPSECURITY_ATTRIBUTES lpAttributes,
DWORD flProtect,
DWORD dwMaximumSizeHigh,
DWORD dwMaximumSizeLow,
LPCTSTR lpName
);
That's the function prototype shown on MSDN, I have a question about the first parameter here: it can be a handle to a disk file if the handle value is not INVALID_HANDLE_VALUE , or else it will be using system page file. I wonder which should I choose, specify a disk file or just use the system page file, which one is better and why? Thanks.
|
|
|
|
|
|
IPC. I'm trying to develop a project that requires a number of processes cooperate together, each of which needs to know exactly what other processes are doing in order to interact properly.
I'm thinking of using file mapping as my IPC approach, I'm not sure if this is a good way, though. Your help is very much appreciated.
|
|
|
|
|
|
File Mapping is a very good technique for IPC, in fact that is how COM implements its underlying IPC for local processes.
Using the system page sounds like a good way to go, then there is no file clean up afterwards. Other than that I do not think that it matters which way you do that.
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!
|
|
|
|
|
Thanks for you and anyone who replied. OK I still have a question here, it may sound stupid but anyway:
Is there any possibility that the mapped file will be trespassed by other process? I mean, if I have process A and B are using the mapped file(I will generate a GUID as mapping file name), is it possible, even very very slightly possible, that any contents within the mapping can be modified by processes other than A and B?
Because I need the contents to be absolutely private and secure to process A and B, this is crucial for me, otherwise I might get fired . So before I begin it I'd like to make sure. Thanks again.
|
|
|
|
|
Bin wrote:
Is there any possibility that the mapped file will be trespassed by other process?
Yes. If you use a named object, a process with the proper security can access that object. Will it? Very unlikely, but still possible.
(Think about it, if process B can see an object owned by process A, so can process C. More importantly, your bosses need to understand that if a process has administrative rights in windows, you simply cannot make the system secure. This is akin to the adage that a physically accessable computer is not fully secure.)
|
|
|
|
|
Hi
there are some programs like MS MediaPlayer and InterVideo WinDVD which, in case of a crash, show a MessageBox with the line, the sourcefile, and a piece of the code that caused the crash. It looks like this e.g:
Unhandled exception in
"C:\Program Files\foo\main.cpp" in line: 289
ASSERT(pFoo != NULL);
How can I implement this feature into my applications?
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Well, I don't think Microsoft and Intervideo deliver debug versions of their programs tp the customers There must be another way.
Furthermore the assertion dialog (or MessageBox) doesn't look the same like in the MediaPlayer or WinDVD.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
Well, I don't think Microsoft and Intervideo deliver debug versions of their programs tp the customers
Well, an ASSERT is suposed to only be present on debug Builds, right?
You can achieve the same by #define _DEBUG on your release build, or creating a proprietary fancy ASSERT macro.
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
While in Debug mode you could use _CrtDbgReport, however that function only exists in the debug version of the C-Runtime libraries. Look at how ATLs ATLASSERT macro works.
#define _ASSERTE(expr) \
do { if (!(expr) && \
(1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, #expr))) \
_CrtDbgBreak(); } while (0)
For release mode you could simply create your own function that reports the data in a message box, and you would use these preprocessor defines to get the line number and file: __FILE__, __LINE__
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!
|
|
|
|
|
I finally managed to create my own macro, could you please take a look whether it is correct? Is seems to work however
void _assert_(void *exp)
{
char err[1024];
sprintf(err, "Assertion Failed!\n\n\"%s\" in line %i.\nASSERT(%s)", \
__FILE__, \
__LINE__, \
exp); \
if(exp)
{
MessageBox(NULL, err,"Fatal Error", MB_OK|MB_ICONSTOP);
PostQuitMessage(0);
}
}
#define _ASSERT_(exp) { _assert_(#exp); }
For testing purposes:
void *pFoo = NULL;
_ASSERT_(pFoo != NULL);
thanks
btw why don't the pre-tags recognise tabs (\t) when I copy and paste my code?
modified 12-Sep-18 21:01pm.
|
|
|
|
|