|
It is failing because the checkbox hasn't been created yet, the check box won't be created until the InitDialog function of CSecondDialog has been completed.
The easiest solution would be to create a BOOL flag for the checkbox, set that and then inside the CSecondDialog::InitDialog do the SetCheck code. Either that or use the built in DDX functionality of CDialog.
Michael
|
|
|
|
|
Well , I successed to create my first ATL and it is works.
But the problem that remains is that I dont success to use full at the controls of the ATL Dialog. [ATL object][Miscellaneous][Dialog]
the code line's :
--------------------------------------------
CEdit* pText = (CEdit*)GetDlgItem(IDC_EDIT1);
pText->SetWindowText("Hello! ");
pText->UpdateWindow();
-------------------------------------------
or:
--------------------------------------------
CStatic* image = (CStatic*)GetDlgItem(IDC_PICTURE);
image->......
.....
----------------------------------------
cause to crush the program in run time.
How can I use at the controls correctly ?
|
|
|
|
|
Where is this code being called from, is it before or after the InitDialog. Also what error message are you getting?
Off the top of my head, I thought the GetDlgItem returned a HWND so you can't cast it to a CEdit.
In my ATL/WTL dialogs I do the following,
declare a CEdit variable in the dialog class
CEdit m_editDest
and then in my InitDialog
m_editDest = GetDlgItem(IDC_NUMBER);
m_editDest.LimitText(64);
Michael
|
|
|
|
|
GetDlgItem returns CWnd* , so the code that mimi writed is correct.
apparently there are another problem.
|
|
|
|
|
CWnd::GetDlgItem returns a CWnd*, but ::GetDlgItem returns a HWND. CWindow::GetDlgItem ( the ATL function ) returns a HWND also.
As the code mimi provides does not call GetDlgItem in the scope of an instance of CWnd, unless it is inside an MFC CWnd derived class, Michael is correct.
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.
|
|
|
|
|
If mimi is using an ATL Wizard created dialog, then CWnd doesn't exist. The only GetDlgItem in the Atl DialogImpl class is the one which returns the HWND. Although looking at the answers further down it looks like he isn't using ATL correctly.
Michael
|
|
|
|
|
Thank you !
1. This my code called from OnOk func of CDialog.
2. The project pass compilation without errors or warnings But in run time when the program arrive to this lines I gets message error that performed illegal action and the program will close.
|
|
|
|
|
In your question you say that you are using an ATL generated Dialog class, but CDialog is an MFC class. Can you post the class defintion so that I can see which kind of framework you are using as I'm getting confused.
Michael
|
|
|
|
|
not CDialog .
But your suggestion cause error at compilation:
It is not returns CEdit
|
|
|
|
|
My fault too. I only gave you half a story. ATL doesn't support CEdit natively. There are two ways you can get a CEdit control in an ATL dialog. The easiest way is to use the WTL headers that come with the platform sdk or secondly you can read the following knowledge base item http://support.microsoft.com/support/kb/articles/Q223/4/39.ASP
Michael
|
|
|
|
|
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
|
|
|
|