|
Hi,
I have created a win32 dll and added a dialog resource.
And I exposed functions which would create a dialog and
work on it.
void MyFun()
{
BOOL blnSuccess ;
g_MySafeDlg = new CMySafeDlg();
MessageBox(NULL,_T("i am in MyFun"),NULL,MB_OK);
if(g_MySafeDlg != NULL)
{
BOOL ret = g_MySafeDlg->Create(IDD_DLG_MYSAFE);
if(!ret)
{
MessageBox(NULL,_T("dialog not created"),NULL,MB_OK);
return ;
}
}
-----
I am getting Dialog not created messagebox.
What could be the problem?
Any suggestions would be helpful.
Thanks
Today is a gift, that's why it is called the present.
modified on Thursday, January 10, 2008 1:03:05 AM
|
|
|
|
|
You can use of Create(IDD_DLG_MYSAFE); on the constructor of CMySafeDlg.
|
|
|
|
|
Problem Solved. I forgot to set the resource handle when
calling from the client
i.e done as below
HINSTANCE hInsta = LoadLibrary(_T("..\\..\\MySafeClDll\\debug\\MySafeClDll.dll"));
AfxSetResourceHandle(hInsta);
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
how to show all of the CStringArray members to editbox that have a cstring variable.
i have some difficulties coz only last member i can show in my editbox ?. , i try it in lzw compression article by The Prince of Chaos(www.codeproject.com/KB/recipes/LZWCompression.aspx)
|
|
|
|
|
ciiiek wrote: i have some difficulties coz only last member i can show in my editbox ?.
I didn't get you... Can you explain a little bit better?
|
|
|
|
|
If you want to show values of CStringArray to editctrl you must keep previous datas of edit ctrl and insert new value to that string of edit ctrl.
|
|
|
|
|
Are you looking for something like this?:
CStringArray szArr;
CString szStr;
szArr.Add(_T("One\r\n"));
szArr.Add(_T("Two\r\n"));
szArr.Add(_T("Three\r\n"));
szStr = szArr.ElementAt(0) + szArr.ElementAt(1) + szArr.ElementAt(2);
m_str = szStr;
UpdateData(false);
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
...formerly known as brahmma
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Dear All,
A strange behavior for drag and drop.
DROPEFFECT_NONE work when using my format but CF_HDROP.
Can some one tell me why and how can I do it ?
Thanks for your great help.
BOOL CtestdragDlg::OnInitDialog()
{
CDialog::OnInitDialog();
::OleInitialize(NULL);
BOOL bRes = m_Target.Register(&m_List);
m_cfFormat = RegisterClipboardFormat(_T("{2FCA1C31-D8F1-4f20-8051-B0CCF7B6FD0D}"));
m_List.InsertColumn(0,_T("First"),0,300);
m_List.InsertItem(0,_T("Hello"));
return TRUE; // return TRUE unless you set the focus to a control
}
HGLOBAL CtestdragDlg::GetData()
{
char Text[5] = "HHHH";
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE,strlen(Text)+1);
char *pChar = (char *)GlobalLock(hGlobal);
strcpy(pChar,Text);
GlobalUnlock(hGlobal);
return hGlobal;
}
void CtestdragDlg::OnLvnBegindragList1(NMHDR *pNMHDR, LRESULT *pResult)
{
COleDataSource DataSource;
HGLOBAL hData = GetData();
if (hData)
{
//DataSource.CacheGlobalData(m_cfFormat,hData);
DataSource.CacheGlobalData(CF_HDROP,hData);
DROPEFFECT DropEffect = DataSource.DoDragDrop();
}
*pResult = 0;
}
DROPEFFECT CMyTarget::OnDragOver(CWnd* pWnd,COleDataObject* pDataObject,DWORD dwKeyState,CPoint point)
{
return DROPEFFECT_NONE;
}
|
|
|
|
|
Hi,
I am a little confused on the use of DLL's first I guess there is a difference between a static load and a Dynamic Load
A LoadLibrary is a Dynamic Load of a Dll So my questions is How can you ensure a DLL is Automatically Loaded when your app/exe starts up ??? (which I guess would be a static Load)
Second If want execute a Function in a DLL I can do A GetProcAddress and use the function or use IMPORT/EXPORT (__declspec) pairs
These are two mutally exclusive way of excuting the function ???
Thankx
|
|
|
|
|
ForNow wrote: which I guess would be a static Load)
yes
ForNow wrote: These are two mutally exclusive way of excuting the function ???
They are not exclusive. Even can mix both this method. How ever if you want to call a function by with any of the aboce technique, the only this you need to ensure is that the function should be exported eith using the __declspec or by adding the entry in the .def file.
|
|
|
|
|
How can you do a static load or ensure that the DLL get loaded when your app/exe starts up
|
|
|
|
|
Suppose you have a function say, void test() exported from a dll( using __declspec or using def file ). when you build the dll, along with the dll and lib file will also be generated.
. Now Declared the function in the exe( usually we include the header file of the dll in which the function is already declared )
.After that you can call the function. Also add the lib file of that dll in the project settings of the exe ( project settings->link->object or library modules).
|
|
|
|
|
The .lib file is the glue
The funny thing about this is when you run a app/exe Windows will somtimes not find because its not in the Path
However I guess it will always find a .DLL anywhere on your machine to Load it
|
|
|
|
|
ForNow wrote: However I guess it will always find a .DLL anywhere on your machine to Load it
I dont think so. The windows will load the dll only if the dll is in working directory of exe or the path of dll is added in the PATH environment variable.
|
|
|
|
|
Okay begining to get the picture thankx for your help
|
|
|
|
|
Well, it is not so funny, roughly speaking:
(1) When you build the application, the linker uses the lib file to place only calling info to DLL functions inside application executable.
(2) When you run the executable the loader needs to find the DLL and make the calls
become effective glued to actual DLL functions.
The OS has well definite strategy to find DLL s, see http://msdn2.microsoft.com/en-us/library/ms682586(VS.85).aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
|
you might be wanting to read this article[^]...
static loading a DLL ensures that the DLL is found when the program starts up. if the DLL is not found, an error message is thrown, and the application stops straight.
|
|
|
|
|
Since
toxcct wrote: static loading a DLL ensures that the DLL is found when the program starts up.
hence
toxcct wrote: if the DLL is not found
cannot happen.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yes it can
I meant, static loading ensures that if the applications is started, the the DLL has been found.
but still the DLL may not be found, thus application bornt dead.
|
|
|
|
|
toxcct wrote: thus application bornt dead
And wasn't it alive before actual birth? Was it?
Oh, this is an arduous ethical debate...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
|
ForNow wrote: first I guess there is a difference between a static load and a Dynamic Load
The difference is actually referred to as implicit vs. explicit linking.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is there a way to read with/write into databases with C++?
|
|
|
|
|