|
Sorry, actually i meant to post to the original question.
Usually the dlls loaded and mapped into process memory space during application startup. Well, if you mark the dll as "delayed loading dll" then that particular dll will be loaded only during the "first call" to any of the dll exported function. And you can avoid LoadLibrary() and GetProcAddress() functions if you really want the dll to be loaded during runtime.
Well check these links about - How to mark a dll as delayed loading dll[^] and Delayed Loading Dll article[^] in codeproject.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, November 23, 2008 7:00 AM
|
|
|
|
|
franco nero wrote: if yes, when does this happen ? On application startup or when the dll is called for the first time?
At application startup, unless you "late bind" to the DLL (i.e. load
the DLL with LoadLibrary()), in which case it happens when LoadLibrary()
is called.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Usually the dlls loaded and mapped into process memory space during application startup. Well, if you mark the dll as "delayed loading dll" then that particular dll will be loaded only during the "first call" to any of the dll exported function. And you can avoid LoadLibrary() and GetProcAddress() functions if you really want the dll to be loaded during runtime.
Well check these links about - How to mark dll as delay loading dll[^] and Delayed Loading Dll article[^] in codeproject.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, November 23, 2008 8:26 AM
|
|
|
|
|
Hi,
i need some expert design guidelines for a real time 3D graphics application using Visual C++. These advices may be high level for extensibility or low level for performance issues. i’m getting confused at some parts of design like syncronization of frame loop with real time data and processing realtime data without buffer overruns etc,, so let me explain application details and some points that needs your expertise.
From now on i will use the following acronmys;
- APP, main application (an SDI MFC executable - .exe),
- DllMan, an MFC Extension DLL ( .dll) that includes a Plug-In Manager and Base Plug-In and utility classes that is statically linked to APP,
- PlugIn#N, a number of MFC Extension DLLs (PlugIn#1.dll, PlugIn#2.dll) that is managed and dynamically linked by DllMan which includes derived Plug-In Classes and Socket and DB utiliy classes to get realtime UDP packets over network and process them, update entity states and record incoming data to Database for offline replay/playback.
APP will statically be linked with DllMan and at startup DllMan dynamically loads up PlugIn#N. APP will display a 3D view of entities by using a 3D Scene graph and rendering library. User will zoom in/out, pan on the screen and be enabled to start/stop recording realtime data and replay all mission by using recorded data by offline.
In order to maintain a reasonable frame rate and realtime data sync, i need your expertise regarding how should i design APP, DllMan and PlugIn#N?
Let me tell you abit about my PlugIn#N design. Each plug-in module contains a derived class which inherits some basic implementation and interface from base plug-in class in DllMan module. Each plug-in basically implements an entity that will be drawn on 3D View. Entity data is coming from network at 50 hz rate by UDP packets. So by design each entity has its own plug-in module and get its realtime data on its own UDP port. There will be thread-safe Queue to work as a data packet buffer, a worker thread to process data packets, update entity state and record incoming packet to database. During realtime operating mode data comes from network but while offline packets shall be queued from Database records and a similar processing will take place. During offline replaying, user shall have full control on 3D scene by jumping, rewinding any instant on recorded mission data. Bu in realtime mode user will just enable to zoom in/out on 3D scene.
1- My first question will be about realtime data processing. Lets consider there is only one plug-in module PlugIn#1 loaded and UDP packets are coming with (50 hz ). To prevent buffer overruns on Recv() what should i do? Should i put received bytes ( a message structure indeed) immediately into a thread safe Queue and notify waiting worker thread to process incoming data?
2- Second question is about realtime data synchronization. APP side will have a frame loop to update frame data and draw. Since most of our frame data is inside PlugIn#N because of that entities are created under each plug-in module automatically and put inside a list managed by DllMan. APP will request DllMan to get entities updated for each frame to draw 3D scene. APP will use DllMan to iterate each PlugIn#N each frame. So what gets me really confused is that. Should there be a syncronization between APP+DllMan & PlugIn#N since there may be a worker thread inside PlugIn#N. What should be the relation between this kind of application to properly render entities with each incoming realtime data. i’m getting confused regarding how is it possible to use all data by APP and no state overlap will be prevented between next incoming data and current state?? This point is so important for me to understand.. Pls could you explain in detail if you have any experience?
3- What should be done to maintain a reasonable overall frame rate like 30 fps? Should i use CwinApp::OnIdle()? Or should i use some high frequency timing mechanism? Or any worker threads at APP side other than main thread?
4- What happens if APP tries to achieve a 30 Hz frame rate but 50 hz realtime data is coming from network? Is it possible to handle such data rate? if possible i’m wondering how? Since 3D scene draw time is full of terrain, 3D models, 2D Overlays and geometries?
5- What happens the runtime performance if more than one PlugIn#N module is loaded? Since each PlugIn#N module architecture will be similar so each one will have Queues threads db connections..etc should i consider on overall achitecture? Since plug in architecture is considered to achieve flexibility whenever new mission entities are required and building a new entitiy would have no effect on APP+DllM side in theory. By this way we would get rid of modifying working part to integrate a new module in the future. But that architecture will make no sense if 3D performance is not reasonable.
thanks in advance
for your patience and precious comments..
regards,
atilla.
|
|
|
|
|
Hi i using an application in that i am using char**
Usually in UNICODE settings we can represent
char* as LPCTSTR my question is How to represent char** in UNICODE
please help me
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
I'm not sure what you mean but i think what you need is WCHAR or wchar_t (or maybe simply short). So WCHAR** or wchar_t** (or short**), LPCWSTR.
|
|
|
|
|
|
You may use TCHAR ** or LPTSTR * .
BTW
krishnakumartm wrote: Usually in UNICODE settings we can represent
char* as LPCTSTR
Is wrong, in fact you use a LPTSTR as generic text mapping for char * (and wchar * ).
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Problem: A User is using "copy and Paste" from a MS Word and MS Works database to enter data into my nprogram. And it fails to accept the special chars contained in each database. How do I strip those special chars from those databases before the User can "copy and Paste" from them?
Heres how I extract the data from my database file into a vector:
void CSystemDB::ConvertStringFromFileSys(CString str)
{
// Take the string data from the file and convert it back to
m_vSys.m_vSysData.clear();
CString e = "";
CString s = "";
CString c = "";
CString d = "";
CString x = "";
m_cSysData.CleanUp();
int sizeOfString = str.GetLength() + 1;
LPTSTR lpsz = new TCHAR[sizeOfString]; //[sizeOfString];
_tcscpy_s(lpsz, sizeOfString, str);
int nStop = 0;
int i = 0;
int ntmp = 0;
int ntmp2 = 0;
d = '*';
e = "";
c = ',';
int ch = 0;
int nQuit = 1;
int nLastchr = sizeOfString - 1;
int index = 1;
for(i = 0; i < nLastchr; i++)
{
switch(index)
{
case 1:// Get m_csOperatorName:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Have m_csOperatorName:
m_cSysData.m_csOperatorName = s;
index++;
break;
case 2:// Now get m_csWellName:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Have m_csWellName:
m_cSysData.m_csWellName = s;
index++;
break;
case 3:// Get m_csOperator_sdb_FilePath:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Have m_csOperator_sdb_FilePath:
m_cSysData.m_csOperator_sdb_FilePath = s;
index++;
break;
case 4:// Now get m_csWell_wdb_FilePath:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
x = "";
}// while(nStop == 1)
// Got m_csWell_wdb_FilePath
m_cSysData.m_csWell_wdb_FilePath = s;
index++;
break;
case 5:// Now Get m_IsFileName:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if( x == c)
{
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Got m_IsFileName:
m_cSysData.m_IsFileName = s;
index++;
break;
case 6:// Now get m_csDirections
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
//
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Got m_csDirections
m_cSysData.m_csDirections = s;
index++;
break;
case 7:// Now get m_csTanks:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
//
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Got m_csTanks:
m_cSysData.m_csTanks = s;
index++;
break;
case 8:// Now get m_cs210Wtr:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
// Got m_cs210Wtr:
m_cSysData.m_cs210Wtr = s;
index++;
break;
case 9:// Now get m_cs210Oil:
s = "";
nStop = 1;
while(nStop == 1)
{
x = "";
x = lpsz[i];
if(x == c)
{
// a comma exist
x = "";
nStop = 0;
}
if(x == d)
{
// was '*' end of SysData record
x = "";
nStop = 0;
}
else
{
s += lpsz[i];
i++;
}
}//while(nStop == 1)
m_cSysData.m_cs210Oil = s;
//Got all data put in vector:
m_vSys.m_vSysData.push_back(m_cSysData);
m_cSysData.CleanUp();
s = "";
index = 1;
break;
}// switch
if(i >= nLastchr)
{
break;
}
}//for(...)
delete [] lpsz;
}
I thought about loading another(or several) CStrings with "OD' OR 'OA' Ex: CString CR = 'OD'; but I don't know if that would work in the example code above.
Any help would be appreciated. This is MFC VS2008 code.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: How do I strip those special chars from those databases before the User can "copy and Paste" from them?
Can you handle the WM_PASTE message?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
As you can see by the code I presented, No. That code segment is where I read from the file what the User typed(or pasted in). It's here that I need to strip the Special chars, etc from the database.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: It's here that I need to strip the Special chars, etc from the database.
And what are those special characters? What does the input look like? What should the output be?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All,
I have a doubt in costum tree control.I created a CDragDropTreeCtrl for drag and drop purpose.
The code is:
RECT rect = {25,29,190,250};
m_treeCtrl1.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_TRACKSELECT|TVS_SHOWSELALWAYS ,
rect,this, 1001);
rect.left = rect.right + 25;
rect.right = rect.left + 170;
m_treeCtrl1.SetBkColor(RGB(192,192,192));
m_treeCtrl2.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT
|TVS_HASBUTTONS|TVS_TRACKSELECT|TVS_SHOWSELALWAYS ,
rect,this, 1002);
m_treeCtrl2.SetBkColor(RGB(192,192,192));
PopulateTree(m_treeCtrl1);
rect.left = rect.right + 25;
rect.right = rect.left + 170;
m_treeCtrl3.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT
|TVS_HASBUTTONS|TVS_TRACKSELECT|TVS_SHOWSELALWAYS ,
rect,this, 1003);
m_treeCtrl3.SetBkColor(RGB(192,192,192));
now i need the double click event for this tree control.I dont know how to write it.Bcoz it doesnt have the ID(because custom tree control).
Pls help me...............
Thanks & Regards,
Anitha
|
|
|
|
|
You can use the WM_NOTIFY with the NM_RCLICK message. Such as:
ON_NOTIFY(NM_CLICK, IDC_TREE1, OnClickTree1)
ON_NOTIFY(NM_RCLICK,IDC_TREE1, OnRightClickTree1)
Some documentation here:
How To Display a Context Menu for CTreeCtrl[^]
Best Wishes,
-David Delaune
|
|
|
|
|
u can use ID u provided in ur create method i.e the last argument;in ur
case u have given it as '1001','1002' and map ur events
|
|
|
|
|
Hai !!
How to change the caption of AfxMessageBox ()
i could give the message but the caption remains the name of the project !!
Can i change it ??
Thankyou !
|
|
|
|
|
AfxMessageBox[^] is simply a wrapper for the MessageBox Function[^]. I would suggest that you use that instead if you want to modify the caption.
Best Wishes,
-David Delaune
|
|
|
|
|
Add an entry with the ID AFX_IDS_APP_TITLE to your application's string table, and set the value to the title you want.
|
|
|
|
|
Hello,
My application is an mfc application which is connected to server throughtout.
Now if the internet connection failure is there then then i display a meesgebox that please check your internet connection.
And the applications keeps on requesting from the server.
How ever if the internet connection does not get better early the the appplicaton keep on requesting from thes server i.e. it gets busy in itself as the messagebox next gets fired after 213 calls.
How should i manage it so that it does get busy itself and the user does not have to forcefuuly end it.
Thanks In Advance.
Dhiraj
|
|
|
|
|
Hi, I am programming a simple matrix class with the following = and + operator definitions:
Matrix<T> Matrix<T>::operator=(Matrix<T> rhs)
{
if (v!=NULL)
delete [] (v);
iRows=rhs.iRows;
iCols=rhs.iCols;
v=new T[iRows*iCols];
for (int i=0;i<(iRows*iCols);i++)
*(v+i)=*(rhs.v+i);
return *this;
}
template <class T>
Matrix<T> Matrix<T>::operator+(Matrix<T> rhs)
{
Matrix<T> sum(iRows,iCols);
if (iRows!=rhs.iRows || iCols!=rhs.iCols)
throw Exception("Matrices dimensions do not match", __FILE__, __LINE__);
else
for (int i=0;i<(iRows*iCols);i++)
*(sum.v+i)=*(v+i)+*(rhs.v+i);
return sum;
}
where
private:
int iRows;
int iCols;
T* v;
Now, I try the code: C=A+B,
The point is that before the return sum assings the sum value , the matrix variate sum is destroyed by the Matrix class destructor as it is a local scope variate, and I get a debug assertion error. On the other hand, if I comment the destructor code block, there code works fine.
Thanks in advance.
modified on Sunday, November 23, 2008 5:00 AM
|
|
|
|
|
Why the assignment operator doesn't return a reference, as it should do?
Why didn't you implement also the copy constructor?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You are right. I changed my code so many times, that didn't notice about the assignment operator did not return a reference. Anyway, that is not the problem, I still get my sum variate destroyed before returning anything. what does the copy constructor have to do with the + operator?
|
|
|
|
|
Hi All,
Im having the .bmp file in tree control.If i will click that file, it will open in paint using MFC(I dont want in VC++).
Pls help me...........
Thanks & Regards,
Anitha
|
|
|
|
|
Hello Anitha,
You can use the ShellExecute Function[^] to launch the either the default BMP extension handler or "%windir%\system32\mspaint.exe" with lpParameters set to the file path for only MSPAINT.
Best Wishes,
-David Delaune
|
|
|
|
|
Hello!
I'm not sure i understood correctly what you are trying to achieve there, but if you have the path to the BMP file you want to open when it is clicked you could try using ShellExecute, for example something like ShellExecute(NULL, "edit", <path_to_your_BMP>, NULL, NULL, SW_SHOW) or maybe ShellExecute(NULL, "open", <path_to_paint>, <path_to_BMP>, NULL, SW_SHOW).
|
|
|
|
|