|
Well I added that new twist of the exported function but I still cannot reproduce your problem.
LOGLIBSINGLETON_API Logger& GetLogger();
LOGLIBSINGLETON_API Logger& GetLogger()
{
return Logger::getInstance();
}
Logger& logger = GetLogger();
logger.log( msg, 0, 1, msg);
Logger::release();
I don't understand why you need an exported function that just returns a pointer to an instance but that's just me. Ultimately it does not change the fundamental structure of what you are doing which is why it still behaves exactly the same for me.
IMHO if you need parameters to set up the engine instance you are back to what I orginally suggested anyway. Let the user create an engine and setup the engine using it's interface. If the user must supply these parameters what difference does it make how (what functions/methods) they use to supply them?
Or even add the parameters to the static getInstance(....) method. The global exported functions are zero added vaule as far as I can tell (however they do not seem to be the cause of your error since it works for me).
led mike
|
|
|
|
|
led mike wrote: Well I added that new twist of the exported function but I still cannot reproduce your problem
That's strange... What IDE are you using ? I'm working with VC2005 Express.
led mike wrote: I don't understand why you need an exported function that just returns a pointer to an instance but that's just me.
The reasons are multiple:
- First, I want to force the user to specify some parameters (like the screen size, and several other configurations). If I use several public function to do that it is not clean: some parameters are mandatory and I don't want the user to call 3 or 4 functions to initialize the engine. You said that I could add parameters to the static getInstance: that's quite bad. What happen if in my code, I want to access the unique instance ? I'll need to pass some parameters again ? That's not clean at all.
Remember that I want it the easiest to use for the end user.
- Second, I would like the user to work with interfaces only (so, pure abstract classes only) so, the Create function will in fact instanciate a CEngine class and returns an interface.
- I would like to have this code compile for several platforms (at least for windows and Linux), so having a DLL binary for windows and a 'dynamic library' (I don't remember the extension) for Linux based on exactly the same code. I know for sure that gcc can export functions, but I don't know if it can export classes.
- It could be interesting to have this dll to be explicitely linkable (so, using LoadLibrary and GetProcAddress). If you export classes, you can only use implicit linking (that is, using the lib file provided with the dll).
- I would like in the future that the dll can be used in other languages (for example in .NET). I don't know exactly how I will do that but I know more or less how COM components work: they have a global exported function that creates an instance of a class and returns an interface to this class. So, being able to use this dll in other language will require only to rewrite the interfaces.
So, there are several reasons why I want to keep this design.
Anyway, thanks for your help. I hope I'll find a solution to that problem.
|
|
|
|
|
Cedric Moonen wrote: What IDE are you using ? I'm working with VC2005 Express.
2005 Professional so I doubt that is the problem
Cedric Moonen wrote: If I use several public function to do that it is not clean:
I don't agree with that. The word "clean" is frequently abused in context of software design. If a user is going to use a "rendering engine" they can be assumed to be somewhat technical and should be capable of reading the documentation and sample code that details how to intiialize something as complex as a rendering engine. Have you ever worked with a 3D library?
Cedric Moonen wrote: but I don't know if it can export classes.
That is confusing since the "interfaces" you mention must be exported from your library correct? Therefore it is a requirement for you.
Cedric Moonen wrote: So, being able to use this dll in other language will require only to rewrite the interfaces.
Not sure if I agree with that. Native code is just "wrapped" by managed classes. You would use C++/CLI to create an assembly that implemented managed classes that wrapped all the native classes that you wanted to expose.
led mike
|
|
|
|
|
I think that I don't explain very well
In fact, I would like to have something more or less similar to COM (except that it is much simpler: you just have one exported function that returns the interface of the engine).
led mike wrote: That is confusing since the "interfaces" you mention must be exported from your library correct?
No. They are interfaces and contains only pure virtual functions so in that case I don't need to export anything. By exporting I mean using __declspec(dllexport) . Of course, header files of the dll still needs to be distributed but these headers contains only pure interfaces. It is the way COM components are working.
And thanks for your patience . I'll try to find what is causing the problem. Even if you are right, I still want to understand what is going on here (I don't like when I don't understand what's happening).
|
|
|
|
|
I had a cpp file for the library's DllMain implementation and I put the initializer in that.
|
|
|
|
|
I think the Rick York hint resembles mine: just put the static member initialisation in the DLL cpp (you should have one, at least it is not forbidden...) .
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.
|
|
|
|
|
Is it possible to enumerate the entry points a DLL exports (by name)? How?
TIA
ph
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Do you want to just do it yourself, or do you want to write a program that does it?
If you just want to inspect a DLL, use dumpbin from Visual Studio (actually just a wrapper around link.exe ) or Dependency Walker[^] (also in the Platform SDK).
If you want to write a program to do it, see An In-Depth Look into the Win32 PE File Format[^] from MSDN Magazine.
|
|
|
|
|
the second link might do it (I was *fo course* hoping for some EnumDllExports Win32 API function.. ) - I'm gonna study this next week, thanks
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Hi,
I am experiencing some real trouble with a simple windows program that I am trying to create. After running the CreateDialog() function, windows returns the error "Windows class not created". I am having trouble determing what this message is really telling me.
The result of this error message is that after processing the WM_SETFONT message inside the DlgProc for the Dialog Box that it creates, Windows always processes the WM_DESTROY instead of the WM_INITDIALOG which is the next message that my other working windows programs processes which creates and displays the dialog box. I have posted my WinAPI function below:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,
int nCmdShow)
{
MSG msg;
HWND mainWnd;
hInst = hInstance; // Make instance available globally
InitCommonControls();
// Create a dummy window so the dialog box can have a parent window, then
// create the dialog box itself.
mainWnd = CreateWindow("", "", 0, 0, 0, 0, 0, NULL,(HMENU)-1, hInstance, 0);
MainDlgBox = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_AURACONNECT), mainWnd, (DLGPROC)DlgProc);
DWORD Err = GetLastError();
SetClassLong(mainWnd,GCL_HICON,IDI_EXE);
// Standard Windows message loop
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
I understand that I probably don't need to create a dummy window to create a dialog box. Also, I can't post my DlgProc because it is so large and long, but is this the most likely source of this error?
Thank you for anyone who can offer any help.
Joe
|
|
|
|
|
Can you post the code of the DlgProc ?
Please use pre tags to post code:
<pre>
...your code here...
</pre>
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.
|
|
|
|
|
Ok, its pretty long, but here you go.
<br />
<br />
LRESULT CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
switch(uMsg) <br />
{<br />
<br />
case WM_INITDIALOG:<br />
<br />
return TRUE;<br />
<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam)) <br />
{<br />
<br />
case IDCANCEL:<br />
<br />
DestroyWindow(MainDlgBox);<br />
PostQuitMessage(0);<br />
<br />
return TRUE;<br />
<br />
case IDC_SETIPADDR:
<br />
SendDlgItemMessage(MainDlgBox, IDC_IPADDRESS, IPM_GETADDRESS, 0, (LPARAM)(LPDWORD)NewAddr);<br />
<br />
wsprintf(strAddr,"%d",NewAddr);<br />
<br />
SendCommand(&DataSocket, SET_IP_ADDRESS, sizeof(CommandStruct), messageFromHost);<br />
<br />
strAddr[cSetIP.length] = '\r';<br />
<br />
SendCommand(&DataSocket, strAddr, strlen(strAddr), messageFromHost); <br />
<br />
MessageBox(NULL,"IP Address has been changed sucessfully","Address Changed",MB_OK);<br />
<br />
return TRUE;<br />
<br />
<br />
case IDC_SETIPMASK:<br />
<br />
SendDlgItemMessage(MainDlgBox, IDC_IPMASK, IPM_GETADDRESS, 0, (LPARAM)(LPDWORD)NewMask);<br />
<br />
wsprintf(strAddr,"%d",ConnectAddr);<br />
<br />
SendCommand(&DataSocket, SET_IP_MASK, sizeof(CommandStruct), messageFromHost);<br />
<br />
strAddr[cSetMask.length] = '\r';<br />
<br />
SendCommand(&DataSocket, strAddr, strlen(strAddr), messageFromHost); <br />
<br />
MessageBox(NULL,"IP Mask has been changed sucessfully","Address Changed",MB_OK);<br />
<br />
return TRUE;<br />
<br />
<br />
case IDC_CONNECTBTN:<br />
<br />
WSAStartup(MAKEWORD(2, 0), &wsaData);<br />
<br />
SendDlgItemMessage(MainDlgBox, IDC_CONNECT, IPM_GETADDRESS,0,<br />
(LPARAM)(LPDWORD)ConnectAddr); <br />
<br />
wsprintf(strAddr,"%d",ConnectAddr);<br />
<br />
if(ConnectToSocket(MainDlgBox, &DataSocket, strAddr, DATA_PORT, WINSOCK_DATA_MESSAGE,FD_CONNECT|FD_CLOSE|FD_READ))<br />
MessageBox(NULL,"Connection attempt with AuraNET Headbox was sucessfull!","Connected with AuraNET",NULL);<br />
<br />
else<br />
{ <br />
if(MessageBox(NULL,"Connection attempt with AuraNET Headbox was unsucessfull!","Not Connected with AuraNET",MB_RETRYCANCEL) == IDRETRY)<br />
PostMessage(MainDlgBox,WM_COMMAND,(WPARAM)IDC_CONNECTBTN,0);<br />
<br />
else<br />
return TRUE;<br />
}<br />
<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_DISCONNECTBTN),TRUE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_SETIPADDR),TRUE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_SETIPMASK),TRUE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_GETSTATUS),TRUE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_CONNECTBTN),FALSE);<br />
<br />
<br />
return TRUE;<br />
<br />
case IDC_DISCONNECTBTN:
<br />
if(!DisconnectFromSocket(&DataSocket))<br />
if(MessageBox(NULL,"Attempt to disconnect was unsucessful. Press Retry to attempt to disconnect again, or Cancel to stay connected","Disconnection Failure",MB_RETRYCANCEL) == IDRETRY)<br />
PostMessage(MainDlgBox,WM_COMMAND,(WPARAM)IDC_DISCONNECTBTN,0);<br />
else<br />
return TRUE;<br />
<br />
<br />
WSACleanup();<br />
<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_DISCONNECTBTN),FALSE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_SETIPADDR),FALSE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_SETIPMASK),FALSE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_GETSTATUS),FALSE);<br />
EnableWindow(GetDlgItem(MainDlgBox,IDC_CONNECTBTN),TRUE);<br />
<br />
<br />
return TRUE;
<br />
<br />
case IDC_PAIR:<br />
<br />
SendCommand(&DataSocket, SETUP_PAIR, sizeof(CommandStruct), messageFromHost);<br />
<br />
return TRUE;<br />
<br />
<br />
}<br />
<br />
return TRUE;<br />
<br />
case WINSOCK_DATA_MESSAGE:<br />
<br />
WinsockHeadboxDataMessageLoop(MainDlgBox, wParam , lParam);<br />
<br />
return TRUE;<br />
}<br />
return FALSE; <br />
<br />
}<br />
<br />
Thank you for looking at this.
|
|
|
|
|
Sorry for the delay, but rebuilding a project with that code took a bit of time.
Anyway I don't get any error on my system, where CreateDialog works correctly.
However, MSDN recommends, for modeless dialog, the following behaviour:
while (GetMessage(&msg, NULL, NULL, NULL))
{
if (!IsWindow(hwndGoto) || !IsDialogMessage(hwndGoto, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
to avoid processing not-dialog messages (hwndGoto is the dialog HWND, in the above snippet). I don't know if that helps you.
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.
|
|
|
|
|
if you can build a project with no error on your system would you consider zipping it up and sending it to me/ posting it to see where we differ?
|
|
|
|
|
TheDelChop wrote: would you consider zipping it up and sending it to me
Yes, of course (by the way I need you e-mail address)
TheDelChop wrote: posting it
I don't know how if it is possible to post zip files via the forum.
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.
|
|
|
|
|
JDelCioppio@astromed.com
Thank you so much,
Joe
|
|
|
|
|
Did you try my suggestion in the reply to your other post?
Try changing
SetClassLong(mainWnd,GCL_HICON,IDI_EXE);
to
SetClassLong(mainWnd,GCL_HICON,LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXE));
|
|
|
|
|
Oops...
Should be
SetClassLongPtr(mainWnd, GCL_HICON, (LONG_PTR)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXE)));
And your parent window has no window class registered for it?
Try making the dialog style overlapped and create it with parent HWND = NULL.
Mark
|
|
|
|
|
I have a USB tool that I gets out of sync with the USB handle and locks up my system. Is there a way to set a timer event prior to the execution of the action that sometimes hangs. This way, if it hangs for a give period of time, in the timer event I could abort the commands and reset the tool.
Eric
|
|
|
|
|
I think your tool will hang the timer too (timers act through windows messages).
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.
|
|
|
|
|
How do i capture video without using ICaptureBUilder?
|
|
|
|
|
Hi!!
i am using two method and i have declared variable out side of my method and that variable i am using in both method like ( Cstring mypath)..
Cstring mypath;
void confwebd()
{
mypath = dlg.str ( here i am retriving value "str" from dialouge box and is equal to mypath)
}
Void Webdocu()
{
Here i am using value from Void confwebd ( ie mypath)
}
but when u recall void Webdocu, then value of mypath( in void webdocu ) is not equal to original it was.It changed..
How i can make as original it was... ??
i am not sure, may be have to make global value or what ?? if yes then how?
I know.. it bit complicated to understand but...
Thanking you
Shah Satish
|
|
|
|
|
Using global is very bad practice.
And this is not complete code for sure. Post complete code if possible. That will help others to understand problem easily.
|
|
|
|
|
Hi!!
This is the code of my project..For exm..First time when i call function then
webdocupath = D:shah\myproject\webdocu\parth...ok now when i will call second time then
D:shah\myproject\webdocu
and so on..
I want at any time webdocupath =D:shah\myproject\webdocu\parth
CString webdocupath,pmysection;
void Confwebd()
{
// TODO: Implement the command
CString szIniFileName,ResFilePath;
GetModuleFileName(hArxInstance,szIniFileName.GetBuffer(MAX_PATH), MAX_PATH);
szIniFileName.ReleaseBuffer();
szIniFileName = szIniFileName.Left(szIniFileName.ReverseFind(_T('\\')) +1) + _T("WebDokuConf.ini");
// When resource from this ARX app is needed, just
// instantiate a local CAcModuleResourceOverride
//CAcModuleResourceOverride resOverride;
CConfWebD dlg(CWnd::FromHandle(adsw_acadMainWnd()));
dlg.m_strFileName = szIniFileName;
//SendDlgItemMessage(dlg,IDC_WEBDLIST,CB_GETCURSEL,0,0);
if(dlg.DoModal() == IDOK)
{
pmysection = dlg.str;
webdocupath = dlg.pstr2;
}
}
void Webdocu()
{
ads_name en;
ads_point pt;
AcDbObjectId entId1;
AcDbEntity *pEnt1;
int rc = acedEntSel(NULL,en,pt);
switch(rc)
{
case RTERROR :
acutPrintf(_T("Invalid object."));
return;
break;
case RTCAN :
acutPrintf(_T("User canceled."));
return;
break;
}
AcDbMText *myText;
AcDbBlockReference *pMyBlock;
acdbGetObjectId(entId1, en);
acdbOpenAcDbEntity(pEnt1,entId1,AcDb::kForRead);
acutPrintf(_T("\nClass is:"));
acutPrintf(pEnt1->isA()->name());
if((pEnt1->isKindOf(AcDbBlockReference::desc()))){
pMyBlock = AcDbBlockReference::cast(pEnt1);
acutPrintf(_T("\nSelected Object is block:"));
// Now get the attribs in the block
AcDbObjectIterator *pAttrIt;
AcDbAttribute *pAttrib;
pAttrIt= pMyBlock->attributeIterator();
CString x1, x2;
for (pAttrIt->start(); !pAttrIt->done(); pAttrIt->step()) {
pMyBlock->openAttribute(pAttrib,pAttrIt->objectId(),AcDb::kForRead,Adesk::kFalse);
x1 = pAttrib->textString();
acutPrintf(x1);
acutPrintf(_T("\n"));
pAttrib->close();
}
acutPrintf(_T("\n"));
}
if ((pEnt1->isKindOf(AcDbMText::desc()))){
myText = AcDbMText::cast(pEnt1);
acutPrintf(_T("\nSelected Text is:"));
acutPrintf(myText->contents());
pEnt1->close();
CString mywebdocupath,path1;
webdocupath = webdocupath.Left(webdocupath.ReverseFind(_T('\\')));
path1 = webdocupath.Left(webdocupath.ReverseFind(_T('\\')) + 1)+_T("WebDoku\\");
mywebdocupath = path1 +_T("loopo\\WG_LL.txt");
CString LoopListFile (mywebdocupath);
CStdioFile LoopList;
CFileException e;
CString FileName1,Filename2,Path;
if(LoopList.Open(LoopListFile,CFile::modeRead,&e)){
CString Oneline(""),LoopName(""),FileName("");
int pos1,pos2;
for (int i = 0; i < 4; i++){
while(LoopList.ReadString(Oneline)){
pos1 = Oneline.Find(_T("\1"));
FileName =Oneline.Mid(pos1 +1);
pos2 = FileName.Find(_T("\1"));
if(pos2>0){
FileName1 = FileName.Mid(pos2+1);
}
if(pos1 > 0){
LoopName = Oneline.Left(pos1);
if(LoopName.CompareNoCase(myText->contents()) == 0){
acutPrintf(_T("\nStrings are equal"));
FileName = path1 + FileName1;
ShellExecute(NULL,(_T("open")),(FileName),NULL,NULL,SW_SHOWNORMAL);
return;
break;
}
}
}
}
acutPrintf(_T("\nStrings are not equal"));
}
acutPrintf(_T("\nThere is no selected text in "));
acutPrintf(pmysection);
acutPrintf(_T(" section"));
LoopList.Close();
return;
}
}
Shah Satish
|
|
|
|
|
Shah Satish wrote: Here i am using value from Void confwebd ( ie mypath)
Are you assigning it a new value?
Shah Satish wrote: ...may be have to make global value...
Based on the code snippet you've shown, it already is global.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|