|
It is possible, but you have to use MS Word(MS Office) COM model.
You should use something like (check the dependencies):
#import "VBE6EXT.OLB"
#import "MSO9.DLL"
#import "MSWORD9.OLB"
After that the whole set of MS Word objects is exposed to your program
|
|
|
|
|
Hello
I got a little routine for checking a date field.
Now i want to automatically set the focus to that field by using f.e:
(where EF_DATUMINDIENST is the name of the text field)
(GetDlgItem(EF_DATUMINDIENST))->SetFocus();
but my idea was of making a function with as param. the name of that text field.
now i set for example a
CString fieldname = "EF_DATUMINDIENST"
and i call the routine here:
DoChecksAndSetFocusAt(fieldname);
but in the routine "DoChecksAndSetFocusAt"
i can't set focus on that control becz it believes it is a CString text
fieldname = result;
UpdateData(FALSE);
This of course doesn't work .. but i have no idea of how to make it work
So i want to access the text field correctly.
Can anyone help me?
Thanks
Jens
|
|
|
|
|
make it : DoChecksAndSetFocusAt(UINT id) and just pass the control ID.
in C/C++, there's no way to go from a string to a variable name at run time.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
ok thanks, that worked great!
|
|
|
|
|
Ok
I've created a win32 dll project via VS. In this dll I'm creating dialog boxes and windows be be used by several diffent apps.
Here's an example of my creation of the dialogs:
hTemp =CreateDialog(hInstance,
MAKEINTRESOURCE(IDD_USER_STR_INPUT_DLG),
hWnd,
IuxUserStringInputProc);
if (hTemp == NULL)
error = GetLastError();
But it ALWAYS comes back null and the get last error returns an 1814 error, which is: ERROR_RESOURCE_NAME_NOT_FOUND and MSDN tells me: "The specified resource type can't be found in the image file"
What the heck does that mean? It kinda makes sense what it is telling me in that the resource I'm trying to create isn't there in the dll, but it's in the project and it shows up in my build options, so what gives
any help in the matter is GREATLY appreciated.
Thanks
Dan Willis
|
|
|
|
|
groover4life wrote:
hInstance
See MSDN description for CreateDialog, pay attention to the hInstance argument
|
|
|
|
|
Doh!
Makes perfect sense now. LOL. thanks!
Dan Willis
|
|
|
|
|
Ok digging deeper on this problem.
hInstance
Identifies an instance of the module whose executable file contains the dialog box template
since I am calling the CreateDialog within a function in a dll and passing the Hinstance from the application in, it's not the correct Hinstance.
how do I correct this? do I need to create an imaginary window in the dll before calling the CreateDialog and use the Hinstance from that???
This has me a little confused.
Any suggestions? Thanks!
Dan Willis
|
|
|
|
|
hInstanse is the one that comes in DLLMain. Since it is almost first function that is called when DLL is loaded, you can save the value of it in some local variable, at that time.
|
|
|
|
|
I think you can use
(HINSTANCE)GetModuleHandle( _T("Your DLL File Name Here.dll") );
instead of the hInstance of the application . Or, you can just use the saved hInstance value from DLLMain like AlexO suggested.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
That's exactly what I ended up doing. I try to avoid globals if at all possible. That shared global memory in a windows app can bite ya.
Thanks!
Dan Willis
|
|
|
|
|
Ok,
I've been at coding for a few years now, and I'm just now using the "new" operator. LOL. Now I have a question:
LPCTSTR lpUserStringInput = (LPCTSTR) new LPCTSTR (MAX_STRING_INPUT);
why isn't this valid? I get this error:
:\src\libdialog\libdialog.cpp(71) : error C2440: '=' : cannot convert from 'const int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
So what am I doing wrong? And when I want to delete it I just want to do this:
if (lpUserStringInput != NULL)
delete lpUserStringInput;
right? I know how new/delete work with classes, but on individual variables I dunno. Thanks!
Dan Willis
|
|
|
|
|
Many problems where. First, why use a LPCTSTR? That is a pointer to a constant string. Thus you are allocating a buffer you don't intend to modify?
Second, why are you casting the results of a new? 999 times out of 1000, it means you aren't allocating the right thing. new is specifically designed to not require the need to cast.
Third, "new LPCTSTR" will allocate one or more pointers to constant strings. Not strings themselves.
Last thing, if you want to allocate a string of length MAX_STRING_INPUT, then do this
LPTSTR lpUserStringInput = new TCHAR [MAX_STRING_INPUT];
Also, if you wish to delete an array, you MUST use delete [] and not just delete.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thank you. Clears up alot of things for me
one more thing, when calling delete on an array do I need to loop through the array or does:
delete[] lpUserStringInput;
handle that?
Thanks a lot!!!
Dan Willis
|
|
|
|
|
I'm all set guys. thanks alot!
I learn something new every day from this place Woo Hoo! Maybe one of these days I'll be a decent programmer becuase of all of you.
Thank you.
Dan Willis
|
|
|
|
|
what you wrote roughly translates to
char* p = new char*;
you have to decide what ever you meant to do
char** p = new char*;
or
char* p = new char[25];
P.S. If I may, I would strongly recommend "C Programming Language (2nd Edition)"
by Brian W. Kernighan, Dennis Ritchie, Dennis M. Ritchie
|
|
|
|
|
Thanks AlexO
your recommendation is noted. Looking now for it.
Once again thank you.
Cheers!
Dan Willis
|
|
|
|
|
Hi !!
As I was compiling my C++ project, Visual Studio (6.0) crashed and now, when I open my workspace, I get a message telling me the it cannot access the ClassView information file.....
I cannot see my classes anymore !!!
Does anyone know how I could recover the classview ???
Thank you for your help !
Jerome
|
|
|
|
|
|
Thanks but I don't have any .clw files in my project folder......
Any other idea ??
Jerome
|
|
|
|
|
Have you got the project open in another copy of visual studio?
Sounds stupid and obvious, but I often find myself cursing at a broken classview, only to realise that I'd absent mindedly started visual studio twice (and the first copy has exclusive control over the classview stuff)
A reboot in situations like this can also be a magic fix (assuming you haven't tried that already) - sometimes software just goes mad
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Mmmmhh... I didn't even think about trying to reboot......
It's working fine now ! Thank you !
Jerome
|
|
|
|
|
Glad to hear it.
I've seen plenty of occurances of visual studio just going nuts, and needing a reboot to fix it
Such as tracing through a function that was behaving oddly, only to be able to find an if statement that was deciding that 0 == 1
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I get this problem right after DevStudio crashes on me (which is not very often, fortunately). If I then run it again, and reopen the project, I get that message.
The solution then is to open the TaskManager and search for MSDEV.EXE in the list of processes. I usually find two, the one I just ran and the one that had crashed. You can distinguish them by the CPU time. I kill the old process, reopen the project, and everything's cool.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Hy all,
I'd like to ask to someone if is already happened to see this error message during the Compilation phase.
"type name first seen using 'struct' now seen using 'class'"
Do you know something about it??
Thanks in advance
Andrea
|
|
|
|