|
Using this approach the second call to 'GetTime' refill the time value
effectively erasing the previous value obtained from m_ctlDate.
|
|
|
|
|
Sorry - previous message contains invalid answer. This should work OK:
SYSTEMTIME stDate, stTime;
m_ctlDate.GetTime(&stDate);
m_ctlTime.GetTime(&stTime);
stDate.wHour = stTime.wHour;
stDate.wMinute = stTime.wMinute;
stDate.wSecond = stTime.wSecond;
CTime time = stDate;
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks guys!
What about using Prem's approach?
Instead of CDateTimeCtrl I made the varables CTime with names m_timeTime and m_timeDate
Thus I used this code:
UpdateData();
CTime Time(m_timeDate.GetYear(), m_timeDate.GetMonth(), m_timeDate.GetDay(), m_timeTime.GetHour(), m_timeTime.GetMinute(), m_timeTime.GetSecond());
Seems to be quite easy as well
modified 12-Sep-18 21:01pm.
|
|
|
|
|
For large no. of clients connect to server during the load test,getting the connection refused error,even if at server side the backlog in listen() method of the socket is put to maximum SOMAXCONN and creating the user thread for each user after accept.
How to solve this prob.
|
|
|
|
|
How many do you want it to keep in a backlog? Using SOMAXCONN justs tells the service provider to pick a reasonable value. This value could differ between service providers.
So basically, you can't flood your server with connection questions and expect them all to be placed on the backlog. That would actually be a bad design since you could in theory DOS the server by exhausting its memory with a huge backlog of connection requests.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
You gain nothing by calling listen each time after accept ing. The standard sequence is: listen once and then loop around accept .
Is you're having connections refused, try to speed up your accept -associated code. Your maximum rate of clients served per second is 1/t, where t is the time it takes to your app to accept a client. No backlog will improve that appart from providing some resiliance against temporary rushes. In Winsock 1.1 the maximum backlog is 5 (admittedly a little low), if you're using Winsock 2 you can set a more comfortable backlog size (though the value of SOMAXCONN for Winsock 2 is an overkill (0x7FFFFFFF), and you're better off setting something smaller than that.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How I can copy system registry files in win 2k? (winnt\system32\config\*.*) IMHO... it's posible only under DOS... What is your opinion? Sanks...
|
|
|
|
|
I was wondering how to create an SDI app thats view is one of a Shockwave Flash movie viewer. For example the flash viewer/projector app. I know that you can include it as an ActiveX control in a dialog but how would it work for a doc/view app.
Any examples/tutorials would be greatly appreciated.
.NET or not .NET? MFC is the question......
|
|
|
|
|
You could use a CHtmlView and make it load the .swf file
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Does anyone know if there is a way to return the files from the functions FindFirstFile and FindNextFile sorted by name !?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
|
|
|
|
|
AFAIK, it's not possible. You'll have to sort yourself - just store the names in std::vector and call std::sort.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz Sowinski wrote:
You'll have to sort yourself - just store the names in std::vector and call std::sort.
Just what I expected
Tks Tomasz !
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
|
|
|
|
|
Hi !
I have a SDI application which has the view derived from CFormView (the resource for this view is IDD_CONTAINER).
I have to create some DLLs which will be loaded dynamically at runtime by the SDI application (at some stage only a DLL is loaded).
These DLLs will use the CFormView's resource (IDD_CONTAINER), the view window is actually a container window for those DLLs.
The DLLs are MFC Extension DLL (using shared MFC DLL).
Could anyone explain me how to do that (eventually some examples)?
Many thanks,
Vasile
|
|
|
|
|
With extension DLLs you should have no problems with resources - .exe and all extensions will have their resources chained; all MFC functions dealing with resources will search through all MFC-based modules.
To get access to resource #defines, include resource.h from .exe project in .dll projects.
Anonymous wrote:
I have to create some DLLs which will be loaded dynamically at runtime by the SDI application (at some stage only a DLL is loaded).
?? You mean that there will be no .exe?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The .exe will be that container application...but when the app has to load a new dll, it will unload first any other dll loaded before.
Thanks
|
|
|
|
|
I have done something very similiar recently...
I've used a CTabView in my executable that shows dialogs loaded from extension DLL's.
I pass a controlling class to the DLL, and the dll calls a function to add a tab.
control->AddTab(myDlg->GetSafeHWND()).. the only thing that caused me some headache was the AFX_MANAGE_STATE(AfxGetStaticModuleState()); I had to insert in the correct places...
If you need any help, email me at ashran@god.hackersquest.org, but before you email me, remember there is no god!
/wave
|
|
|
|
|
Hi
I'm going round in circles and could do with some help. I have an application that draws a whole lot of information to a window via a subclass of CView. Now I need to save a copy of what is in the window in a particular format. I thought if I created a new view using a memory device context I could get the system to draw itself to this new view and then pull the required data out of memory but I can't seem to find a way to set up a memory device context with the format that I want (16bit gray scale would be ideal - i'll settle for 8bit if I have to).
CreateDC wants me to specify a lot of stuff about drivers .
CreateCompatibleDC gives me something according to the current system device, but trying to select a bitmap of a particular format into this fails because the two are not compatible. CreateCompatibleBitmap seems to give me a monochrome bitmap.
I'm sure it is very easily done but my brain has gone fuzzy.
|
|
|
|
|
CreateDIBSection accepts BITMAPINFO on input, this allows you to specify the color depth.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Seems a good idea. Now I have the following..
---------------------------------------------------------------------------
CDC dcMem;
dcMem.CreateCompatibleDC(NULL); // Needed otherwise handle is uninitialised
// Set up all the BITMAPINFO data
char pDIBHdr[sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)];
BITMAPINFOHEADER *pBitmapInfoHdr;
RGBQUAD *pRGB;
pBitmapInfoHdr = (BITMAPINFOHEADER *)pDIBHdr;
// Setup the header information for the device independent bitmap which
// is going to be used
pBitmapInfoHdr->biSize = sizeof(BITMAPINFOHEADER);
pBitmapInfoHdr->biWidth = 256;
pBitmapInfoHdr->biHeight = 256;
pBitmapInfoHdr->biPlanes = 1;
pBitmapInfoHdr->biBitCount = 8;
pBitmapInfoHdr->biCompression = 0;
pBitmapInfoHdr->biSizeImage = 0;
pBitmapInfoHdr->biClrUsed = 0;
pRGB = (RGBQUAD *)(pDIBHdr + pBitmapInfoHdr->biSize);
for(int ii=0;ii<256;ii++){
pRGB[ii].rgbRed = ii;
pRGB[ii].rgbGreen = ii;
pRGB[ii].rgbBlue = ii;
}
void* pTmpMem;
CreateDIBSection(dcMem.m_hDC,(BITMAPINFO *)pDIBHdr,DIB_RGB_COLORS,&pTmpMem,NULL,0);
dcMem.Rectangle(CRect(0,0,100,100));
pData = (short *)pTmpMem;
// Now use pData to access the actual data out of the bitmap
--------------------------------------------------------------
The output I now get doesn't reflect the Rectangle draw that I performed.
Should it ? Although I have created this DIB is it selected into the DC as the memory surface onto which the draw functions will be occurring. If not how does one achieve that, so that the draw functions accessed via the DC will write into this DIB.
Thanks
Andrew
|
|
|
|
|
You've forget to select your DIBSection into dcMem. The first paremeter you're passing to CreateDIBSection is used only to initialize DC palette when you pass DIB_PAL_COLORS as 3rd param.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All !
I have read that the C# threading classes in .NET causes an
exception to be thrown in a thread if that thread is being ended
by another thread.
Any idea's on how to implement this with VC 6.0 ? This could provide an
excellent alternative to polling for stop flags.
Kind regards,
Alwin
|
|
|
|
|
March'96 issue of MSJ has the answer, unfortunately, it'll work on NT/2K/XP only. Check the 'QA Win32' by Jeffrey Richter. The article may be in MSDN installed on your HD, if it's not there, check the msdn.microsoft.com.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
this is just an idea.
U heard of 'atexit' . use it to register a fn,
put the handle to the current thread in a global
variable and inside the fn so some thing like this.
HANDLE hOriginalThread ;
viod ThreadFn()
{
atexit(fn) ;
..
..
}
void fn
{
if( GetCurrentThread()!= hOriginalThread)
AfxThrowMemoryException() ;
}
U can work out the way out of global variable .
One last thing, u means of throwning exception is alright
but where will it be caught ?
|
|
|
|
|
There's a number of reasons why this cannot be achieved in general, the most important one being that the compiler often assumes portions of code throw no expceptions and takes advantage of this for optimization. Also, if there's floating point arithmetic involved the issue becomes even more tricky, as these operations are usually performed by a separate coprocessor (you can think of them as performed by a microthread), which yields the approach of "everything can throw an exception" a hard one to handle. Other, less important difficulties are those posed by the hard time programmers will have if they must assume everything can throw --think of how you'd prevent memory leaks in such situations.
First releases of Java included this termination-by-exception approach, but later on they deprecated it for the reasons mentioned.
Of course, these problems can be tackled in C# as this language runs in a strongly managed environment. The downside is resulting poor performance.
That said, you can have a thread inspect for termination conditions and throw accordingly upon calling a selected set of DLL functions (even system functions from KERNEL32, USER32, etc.) Check PJ Naugter's HookImportFunctionByName v1.0 for details.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
does anyone know how to write this as call by constant reference using pointers?? here is what ive been trying to do:
int CComputer::CheckForMoves(const CBoard& rBoard, int depth)
{
CBoard Board = rBoard; <-- but using pointers instead of reference
}
so i can call it in the main function like this:
CheckForMoves(pBoard,1); where pBoard is a pointer of CBoard
is there a way i can do something like that without getting any syntax errors????
cause i have tried all sorts of stuff like that but the compiler wont allow
me to do so....
anyways, thanx for you help
John
|
|
|
|