|
Hello, the codegurus around the world.
Try CWindow to deal with Edit box!
USER_CONVERSION;
CWindow wnd;
CComBSTR bstr;
wnd = GetDlgItem (IDC_EDIT1);
wnd.GetWindowText (&bstr);
wnd.SetWindowText (_T("I like ATL!"));
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
The guide of you (mainly of christian and Masaaki ) was excellent,
Now I have the last question for this project (so I hope):
Which files of the ATL DLL project I need to provide for Delphi except MyAtl.DLL ???
Because in client program in VC++ I need also :MyATL.h and MyATL_i.c.
|
|
|
|
|
I am trying to register my ActiveX control, but it gives me an error of failing under WinNT because i am using an API that needs a special DLL to exist under windows directory and it works only in Win2000 and Win98 platforms. How can I make my control register under WinNT without the need of having this DLL under the system directory?
Daed
|
|
|
|
|
What is the name of the special DLL? If you want the code to work on WintNT you will have to avoid calling the unsupported functions. I usually do this by have a pre-processor define for NT and compiling a special version of my application for NT.
Michael
|
|
|
|
|
The DLL is Msimg32.dll, i need it because i am using AlphaBlend function in one of my control's property. Is there anything i can do at registry time to solve this problem?
Daed
|
|
|
|
|
You need to link dynamically to the DLL import. Load the DLL with LoadLibrary() and try to get the function's address with GetProcAddress(). If that succeeds, then use the pointer GetProcAddress() returns to call the API. If that returns NULL, then the API is not available.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Can you give me an example of how i can do this? or may be a link where i can find more explanation about the subject? Thank you
Daed
|
|
|
|
|
- What means the initialization of a DLL? The function DllMain, or the function LoadLibrary?
- My problem arises from the following taken from MSDN (Ti: DllMain)
You must not call LoadLibrary in the entry-point function, because you may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code.
- After reading the codes, I think LoadLibrary is not the initialization of a Dll.
- But what means the initialization of a DLL?
- Can you help?
Thanks,
Maer
|
|
|
|
|
Hi Maer,
When you wan't to use a DLL in your app you have to load it into your process address space first. This is done by the function LoadLibrary. When LoadLibrary executes it first maps the DLL into the process' address space (this means that if the DLL is already used by another app it is not re-loaded from disk, but setup so the your process can see it in it's own address space). Then it's initialization time! LoadLibrary calls the DllMain function located in the DLL with the dwReason parameter set to DLL_PROCESS_ATTACH. After the DllMain function returns LoadLibrary calls it once again, this time with dwReason set to DLL_THREAD_ATTACH. If both these calls to DllMain succeeds then LoadLibrary returns to your app, giving you the handle to the newly loaded - and initialized - DLL.
The problem you're referring to is if you put another LoadLibrary call in your DllMain function. Say your DLL (DllA) is dependent on a second DLL, DllB, which in turn is dependent on DllA again. In DllA's DllMain function a call to LoadLibrary(DllB) is issued. In DllB's DllMain function a function in DllA is executed. Since DllA is loaded there's no problem in calling the function, but since the DllA is not yet initialized there may be some data that the called function uses that is not set up properly (e.g. MFC state data .
To summarize: LoadLibray performs two tasks: One is to do the physical loading of the DLL (loading from disk, linking all the exported functions), the other is to initialize the DLL. Initialization consists of calling DllMain twice, once with DLL_PROCESS_ATTACH and once with DLL_THREAD_ATTACH.
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"
|
|
|
|
|
- The following sentence if taken from MSDN (ti: DllMain)
Access to the entry point is serialized by the system on a process-wide basis.
- I do not know what means "serialized" and "process-wide basis" here.
- Can you show me an example?
Thanks,
Maer
|
|
|
|
|
This means that any call to DllMain is completed before a new call can be processed.
Imagine you have two threads in your app. Both threads call LoadLibray(YourDLL). If these calls occur concurrently then you could imagine the following scenario: Thread A calls LoadLibrary which calls DllMain with a DLL_PROCESS_ATTACH. During the execution of DllMain the thread is preemted by Thread B, that also calls LoadLibrary which also calls DllMain with a DLL_PROCESS_ATTACH. Now you have two threads that are executing the same piece of code in DllMain concurrently, and this means you'd have to be careful when writing the code to avoid any concurrency issues. What MDSN tells you is that Windows will halt the call from Thread B until the call from Thread A has finalized.
Cheers
Steen.
P.S. Your mail adress still bounces. I get a "Domain not found" error ?!?
"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"
|
|
|
|
|
Hey Guys
I am looking for a quick and easy way to distribute a windows explorer extension DLL. All that really needs to happen is that it is copied to a specified folder then registered.
Has anyone got any ideas
Cheers
Peter
|
|
|
|
|
Well a good old fashioned batch file might work.
echo off
copy mydll.dll c:\windows\system /y
regsvr32 mydll.dll
I do this a lot when I'm distributing applications that are used in house. Just run the batch file and the dll is installed.
Michael
|
|
|
|
|
ewww, never copy anything into \windows\system. Take an extra 10 seconds of typing and make a directory under \Program Files (that's what Program Files is there for).
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
sorry, I was just using it as an example copy command. It was the first directory that popped into my head.
Michael
|
|
|
|
|
No need to apologize. I was actually making that comment for the original poster, to indicate that copying to \windows\system is generally not a Good Idea. Sorry for any miscommunication on my part.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Hey Guys
I am looking for a quick and easy way to distribute a windows explorer extension DLL. All that really needs to happen is that it is copied to a specified folder then registered.
Has anyone got any ideas
Cheers
Peter
|
|
|
|
|
I have an MFC dialog which uses a menu resource for its menu. How o i enable/gray menu items?
thanx
Kuniva
|
|
|
|
|
In class wizard you click on the items ID and you get two options, the first is for clicking on the item, the second is basically a callback called just before a menu item is shown. If you override it, you will get a pointer to that one item passed into the function, and you can do whatever you want to it there, by defining a function that will disable your item ( for example ) based on whatever criteria you want to decicde if it is disabled or enabled. You can also check/uncheck, rename, etc. the item here.
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.
|
|
|
|
|
eh yeh, i kinda figured that out, but do you know what function i can use to disable/gray/enable it? Because EnableMenuItem() needs a HMENU parameter and i dont have that because the menu is purely resource based or can i get a HMENU identifier for the menu with another function?
Kuniva
|
|
|
|
|
The pointer coming in to that function is all you need - it has methods like enable, settext, setcheck. So you just operate on the CCmdUI pointer passed in to the function.
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.
|
|
|
|
|
I have a string,but i don't know how delete it in a .txt file?
Please tell me,OK!!!
I'm very like VC++.
|
|
|
|
|
Do loop, search the string in the file.
nothing but everything
|
|
|
|
|
- Why we often discuss the two topics together?
- For example, MSDN topic: DllMain, TlsAlloc, etc.
Thanks,
Maer
|
|
|
|
|
A DLL isn't a thread. A DLL is a separate piece of library code which can be used to separate a program into component parts. These components parts can be shared among more than one program.
A Thread is a bit like a separate path of execution. One program can run multiple threads which means that it can be performing more than one task at a time.
This is a very basic overview. I'm sure there will be some more in-depth articles on the site in the Threads and Processes section.
--
Andrew.
|
|
|
|