|
Please, help me ...
Do you know where is the Windows 2000 registry key for time divison? how can it be modified?
|
|
|
|
|
Hi,
Im trying to scale a DC of a CWnd derivade (NOT CVIEW) and im not getting any success.
Ive tried
CDC::ScaleWindowExt(...)
and
CDC::ScaleViewportExt(...),
among others. Also im using scroll bars in that window... does that affect it?
Thanks in advanced
|
|
|
|
|
What mapping mode are you using...?
MM_ISOTROPIC ...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Ive already tried with MM_ISOTROPIC and MM_ANISOTROPIC and MM_TEXT, but no success so far. Right now, i dont have a limitation in using any of type of mapping mode. Maybe im using it wrong. U have a good example?
|
|
|
|
|
One of my books shows exactly how this is accomplished...if I have some spare time in the next few i'll look into for you if someone hasn't answered it already...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I managed to get this doing something like what you want (i think) but i'm gonna count on you to figure out how it works...
OnPaint() : // make sure you call invalidate inside OnSize()
CPaintDC dc(this);
CRect rect;
GetClientRect(rect);
dc.SetMapMode(MM_ISOTROPIC);
dc.SetWindowExt(rect.Width(), rect.Height());
dc.SetViewportOrg(0, 0);
dc.LineTo(CPoint(200, 200));
dc.LineTo(CPoint(0, 200));
dc.LineTo(CPoint(200, 0));
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
k, i found how it can work, but it needs some changes:
U have to call CDC::SetViewportExt(...)
It works something like this:
1st SetMapMode(MM_ISOTROPIC)
2nd SetWindowExt(200,300) - carefull here, cause it sets the portion of the window to be considered
3rd SetViewportExt(rect.Width(), rect.Height()), to set the corresponding size of the "view"
thanks for the guidance
|
|
|
|
|
Hey again!
I haver found something in the MSDN:
CRITICAL_SECTION GlobalCriticalSection;
InitializeCriticalSection(&GlobalCriticalSection);
__try
{
EnterCriticalSection(&GlobalCriticalSection);
}
__finally
{
LeaveCriticalSection(&GlobalCriticalSection);
}
Inside the try clause I access all my global data I want to access in my thread and other running threads that try access the same data has to wait untill the critical section is over (in the finally clause)... RIGHT?
Did I understand this code right or wrong?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Inside the try clause I access all my global data I want to access in my thread and other running threads that try access the same data has to wait untill the critical section is over (in the finally clause)... RIGHT?
Err... Half-wrong...
Only between the EnterCriticalSection and LeaveCriticalSection.
The __try/__finally is there only to assure that even when there's an exception or a SEH (aka GPF) you call LeaveCriticalSection, because this could lead to the locks being held forever if not done this way.
Q261186 - Computer Randomly Plays Classical Music
|
|
|
|
|
Daniel Turini wrote:
Only between the EnterCriticalSection and LeaveCriticalSection
Yeah but it was something like that I mant!
But when __try has finished __finally will be next jump in the code, isn't it?
and did you mean that EnterCriticalSection will lock for ever if I don't have an __try/__finally statement?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
and did you mean that EnterCriticalSection will lock for ever if I don't have an __try/__finally statement?
MAY lock forever, not WILL lock forever.
If you have a bug in the code between the Enter/Leave pair, your code may not execute the Leave part, leaving the CS locked forever.
So, take care with the code you put between this.
That's why the __try/__finally is there: as an assurance that the Leave will execute always, even on crash or error situations.
Q261186 - Computer Randomly Plays Classical Music
|
|
|
|
|
I personally don't like the __try/__finally. If an error happens that leaves the global data in an unstable state, simply releasing the critical section, absent anything else, isn't going to make the code any more stable and arguably less.
|
|
|
|
|
Basically yes. Be aware, however, that the critical section should be as short as possible to prevent thread stalling. I would examine your global data carefully to make sure you aren't guarding things that don't need guarding.
In other words, if the global data in question is a series of unrelated items, you don't want to guard all of them with a single critical section; a common mistake.
Also be aware that if you need to share a single value, check out the Interlocked...() series of calls.
|
|
|
|
|
Joe Woodbury wrote:
I would examine your global data carefully to make sure you aren't guarding things that don't need guarding.
I'm working on a server that will save all clients in a global std::list object. When a client whants to send to another client on the server, the client iterate through the std::list object and send the message to all clients.
Isn't it good to make a critical section here?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Yes. I think (I'm still not clear how many threads you have, etc.)
(Since it looks like you have a one writer, multiple readers issue, the CriticalSection will block all readers even when a write isn't being done. However, there is no synchronization object designed specifically for this, though you can make a compound object. I have and in real world testing it was much slower than plain Critical Sections. However, this assumes that the read operations are extremely short and can easily occur in a single time slice.)
|
|
|
|
|
Joe Woodbury wrote:
I'm still not clear how many threads you have, etc.)
I will have about 100 threads only.
perhaps 150, but for now 100 is what the first version of my server will have.
Joe Woodbury wrote:
(Since it looks like you have a one writer, multiple readers issue, the CriticalSection will block all readers even when a write isn't being done. However, there is no synchronization object designed specifically for this, though you can make a compound object. I have and in real world testing it was much slower than plain Critical Sections. However, this assumes that the read operations are extremely short and can easily occur in a single time slice.)
But if don't make up a critical section when I read the object?
As Moak said in the message down here it is always safe to READ a global data in multiply threads. then it would be safe, wouldn't it?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
You should seriously consider using I/O completion ports. It's perfect for what you're doing.
|
|
|
|
|
Where can I read more about that!?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
The MSDN documentation has a hopelessly incomplete description. The best discussion is in an out-of-print Jeffrey Richter book "Programming Server-Side Applications for Microsoft Windows 2000."
Perhaps, someone should ask Richter if CP can "reprint" the chapter.
|
|
|
|
|
Rickard Andersson wrote:
I'm working on a server that will save all clients in a global std::list object. When a client whants to send to another client on the server, the client iterate through the std::list object and send the message to all clients.
Hej Rickard,
with a mutithreading socket concept this is a must have IMHO. Reading isn't critical, but changing or removing elements from a list: Another task could e.g. remove an element from the list (when a client signs off), which could invalid the iterator used by another thread. So, that's why you have to make exclusive access to your global network data, no matter if threads wants to read or write.
|
|
|
|
|
Thaaaaaaaaaaank you Moak!
See your ICQ for an important message from me!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
no problem... mompl, starting ICQ...
|
|
|
|
|
[ Returning to the doc-view architecture after 8 years, so excuse the lameness of this question! ]
I have an MDI app that's capable of displaying documents of type CFooDoc and CBarDoc . I've modified the file opening logic to restrict the number of open CFooDoc documents to 1.
What I want to do is automagically close all CBarDoc documents when the user closes the solitary CFooDoc document. I can do this by calling the CloseAllDocuments() on CBarDoc 's doc template.
My question is, how do I detect that the CFooView is closing?
Thanks,
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Never mind. I just overrode the parent frame's OnClose() .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
Or in ~CFooView() or CFooView::PostNCDestroy() or ...
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|