|
Hi
Am not sure if it will work or if its the correct way.
Created a shared variable, so that this variable will be shared among the all the loaded Dll.
#pragma data_seg(".DAT")
int NumberofInstance 0
#pragma data_seg()
..
..
NumberofInstance++;
if(NumberofInstance>1)
{
Dont load the DLL.
}
in the Def file add this
SECTIONS
.DAT Read Write Shared
Hope this will help you.
Regards
Mohamed Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi and thanks for the reply!
That is exactly what I need to do. I would have accomplished it by now if it wasn't for one thing: this Dll of mine has MFC support and thus I don't have access to the DllMain procedure! I do have access to CWinApp::InitInstance . How can I prevent the Dll from loading twice?
Perhaps I'm just confusing (and confused) with all this Dll business...
|
|
|
|
|
check if this console window exists from DllMain and create it if now.
Then create an API for writing text on that window. The API should get the window handle from the console window and send messages to it which are processed then in the process context that created the window.
Don't try it, just do it!
|
|
|
|
|
I'm using the VS.Net 2003 IDE and it doesn't set up CFormView-based apps with print and print and print preview functionality. But since all the overridable member functions are there, I would like to add an event handler for my menu item that sets up the CDC and CPrintInfo members to use to call the overridden OnPreparePrinting and other functions so that I can call print preview. I tried filling in what I thought were the appropriate members of the CPrintInfo structure and calling OnPreparePrinting which, looking through the MFC source creates a printer hdc if you don't have one supplied, but it doesn't work. First of all, it ASSERTs on VERIFY(pInfo->m_strPageDesc.LoadString(AFX_IDS_PREVIEWPAGEDESC)); and even if I step over that line, nothing happens. Any help would be greatly appreciated. Thanks in advance
[insert witty comment here]
bdiamond
|
|
|
|
|
I want to load Core of Word in a MFC project.
|
|
|
|
|
Ok, so use Word Automation.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Does anyone know of a macro or add-in that will take a text selection and automatically add it to the string table and replace the text with the new string table ID?
Dave
|
|
|
|
|
I want to protect my ActiveX!?
|
|
|
|
|
Hi,Dears
how can i get character in CString Object?
How can i convert information to char*?
I confuse between this type of data!
Thanks for your attention.
best regards.
MJM.
|
|
|
|
|
To get caracter use GetAt(n).
To get string as char* use (LPCTSTR)
Sample:
CString str = "Practice";<br />
<br />
char* test = (LPCTSTR)str;<br />
ASSERT(str.GetAt(0) == 'P');
Also test GetBuffer().
Don't forget to call RealeseBuffer() after GetBuffer.
CString sWinDir;<br />
GetWindowsDirectory(sWinDir.GetBuffer(MAX_PATH+1), MAX_PATH+1);<br />
sWinDir.RealeseBuffer();
|
|
|
|
|
|
|
mostafa_pasha wrote:
how can i get character in CString Object?
For a single character:
CString str('B');
str = 'A'; mostafa_pasha wrote:
How can i convert information to char*?
For what purpose? If you have a need to modify the interal CString object, use the GetBuffer() method. If modification is not necessary, simply use the LPCTSTR operator.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i do not have a need to modify. but there is some way i copy this to
heap that i create with HeapAlloc ?
|
|
|
|
|
This is C++. Use the new operator! HeapAlloc() and its family are so 16-bit!
That soap-box aside, what are you needing to do with the CString object?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
for example i create Heap:
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
ghWriterHeap = HeapCreate(0, sysInfo.dwPageSize*2, sysInfo.dwPageSize*4);
if (ghWriterHeap == NULL)
AfxMessageBox("Heap error");
lpBuf = (char *)HeapAlloc(ghWriterHeap, HEAP_ZERO_MEMORY, 512);
and then i Use CString of Edit Control :
i wanna use information of CString and Copy these data to lpBuf!
How can i?
Best Regards.
;)
|
|
|
|
|
mostafa_pasha wrote:
i wanna use information of CString and Copy these data to lpBuf!
How can i?
Try:
CString str;
lpBuf = new char[512];
lstrcpy(lpBuf, str);
...
delete [] lpBuf; But why can't you just use the CString object directly rather than making a copy of its contents?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi again,
Still trying to get rid of a flicker effect whilst trying to display 2 alternating monochrome bitmaps. I've gone down all the usual routes of double buffering and overriding the OnEraseBackgnd function calls, but still no luck. I still get what appears to be part of the 2nd image being displayed on the first - and eventually swapping over with it so that the 2nd image dominates the first over the course of around 5000 frames (if that makes sense). There's no sign of the background colour being drawn BTW.
It has been suggested that I need to synch the drawing with the vertical blank pulse using directdraw. Is there an easy (ie few lines) of code that can do this? eg can I just create a DirectDraw object and call WaitForVerticalBlank, then use my Blt as usual? If not could anyone please let me know what I need to do to implement the directdraw stuff?
I'm using NT4 and the code is largely mfc based.
Any help much appreciated!
|
|
|
|
|
Can you tell me what sort of display rates you get / what rates you are trying to get?
Is it possible that the problem may be related to updating too fast, so both images actually get updated during the vertical blanking, and you only get to see the second image?
To check, try slowing down the display (delay loop or timer), to see if it works flicker-free with updates at 1 Hz, then gradually speed it up until you get to the required frame rate.
|
|
|
|
|
Hello there,
Thanks for your message. I'm trying to achieve single frame rates, ie displaying the two alternating images at the monitor refresh rate. Slowing the process down does indeed get rid of the problem, but unfortunately that's not an option The WaitForVerticalBlank function seems to be what I need - I've tried using someone's code from this website to incorporate the directdraw functions in a test which seems to work, but can't seem to incorporate my bitmap data with the directdraw functions. What seems easiest would be to call the WaitFor... function then do my normal Blt operations, so as not to get bogged down in complicated Directdraw stuff. Can you provide any assistance in how to do this?
thanks a lot
NICK
|
|
|
|
|
I can't claim to be anything like an expert - I was having a semi-educated guess! I have used mainly SDK-level graphics - SetDIBitsToDevice() - as well as a DirectDraw library supplied by a frame grabber supplier.
But some more on my ideas . . .
Do you know what rate your application actually displays the bitmaps? Is it possible that within a single vertical blanking period, you actually try to display both bitmaps? That might give the appearance you describe.
According to the Microsoft DirectDraw documentation, it should be sufficient to do something like:
while not finished<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKBEGIN . . .)<br />
displayBitmap1<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKBEGIN . . .)<br />
displayBitmap2<br />
endWhile
What I have seen by profiling is that the DirectDraw functions return control to the application almost instantaneously, so if WaitForVerticalBlank(. . . DDWAITVB_BLOCKBEGIN . . .) actually returns if you are IN the vertical blanking period, not just at the START of the vertical blanking period, multiple bitmaps may be displayed in the same vertical blanking period.
It may thus be necessary to sit in a loop like this:
while not finished<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKBEGIN . . .)<br />
displayBitmap1<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKEND . . .)<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKBEGIN . . .)<br />
displayBitmap2<br />
WaitForVerticalBlank(. . . DDWAITVB_BLOCKEND . . .)<br />
endWhile
Of course, Microsoft documentation may be correct, in which case explicitly waiting for the end of vertical blanking is not necessary.
I hope this makes sense.
|
|
|
|
|
Norman (and all), Many thanks for your help, I have just managed to solve the problem and the images update flicker free and in synch at a rate of around 30Hz. I found I didn't use the WaitFor(...BLOCKEND...) call as it worked fine with just the (...BLOCKBEGIN). One thing I notice is that the WaitFor functions usually take at least 2 frames worth of timne to respond, which is starnge since I thought they should return after a single frame, but tis a small niggle! Any thoughts though?
Thanks again for your help - the past few weeks have been a struggle to say the least and this site's help has been superb!
best wishes
NICK
|
|
|
|
|
I use :
Visual C++ 6.0
Windows 2000
MsChart Active X
I want :
When I click on the chart I want a lengend(box or what MsChart purpose) with the value of the point. Please help me.
P.S. I'm French and not verry good in English lol.
Thank You see ya
|
|
|
|
|
Hi,
I'm learning about the Doc/View method of programming and making an application. It seems to me that the only way you modify your document is either from the OnOpenDocument() and Serialize() and I have no idea how these get called in the CApp object. What if I wanted to update the document when some function gets called in one of my own objects?
How is the document normaly modified? Do you override Serialize in your app class and then since theApp is global your other objects can access and call it? Do you somehow get the CDocument (by calling something like CFrameWnd::GetActiveDocument())?
What I'm trying to do is have an object that outputs some information to a file. When this object is done I want the CDocument to be updated to point to a different file or something.
Thanks.
|
|
|
|
|
budric@mailinator.com wrote:
...OnOpenDocument() and Serialize() and I have no idea how these get called in the CApp object.
OnOpenDocument() is called by the framework as part of the File/Open command. Serialize() is called indirectly from within OnOpenDocument() .
budric@mailinator.com wrote:
What if I wanted to update the document when some function gets called in one of my own objects?
No problem. Your document has various member variables that can be updated whenever necessary. For instance, my document might have an int member variable called m_nAge . I might prompt the user for their birthdate, and calculate their current age into the m_nAge variable. I would then call SetModifiedFlag(TRUE) to indicate that the document has been changed. Now if I close the application, the framework will check to see if the document has changed and if it so, will prompt me to save it.
Start with something very simple. Create an SDI application using AppWizard. Base the view off of CFormView . Using the resource editor, add a few edit controls (e.g., name , address , ZIP ) to the view. Add corresponding variables to the document (e.g., name and address would be CString , while ZIP would be an int ). Modify the document's Serialize() method to load and store those variables accordingly. Add three edit control variables to the view. In the view's OnUpdate() method, call the GetDocument() method to get a pointer to the associated document. Now call each edit control's SetWindowText() method using the variables from the document. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|