|
i m doing like this.
class CTimerTh :: CWinThread
{
}
class CMy_Th::CTimerTh
{
}
//i create thread with AfxBeginThread and use here CMy_Th as run time class and and save its return pointer in std::map<int, CMy_Th*> ass
ass[0] = (CMy_Th*) AfxBeginThread( RUNTIME_CLASS(CMy_Th),THREAD_PRIORITY_NORMAL, NULL,CREATE_SUSPENDED,
NULL);
std::map<int, CMy_Th*>::iterator pos = ass.find(0);
if(pos != ass.end())
{
if(pos->second!=NULL)
{
CMy_Th* pThread = pos->second;
pThread->PostThreadMessage(WM_QUIT,NULL,NULL);
}
ass.erase(pos);
}
</pre>
please me to resolve the error.
thanks in advance.
|
|
|
|
|
Le@rner wrote: pThread->PostThreadMessage(WM_QUIT,NULL,NULL);
See here. I prefer to let threads kill themselves, and use events to signal between them.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
hi all,
i m working on SDI type application ,i want to set some minimum size of application.
please tell me how can i do this.
thanks in advance
|
|
|
|
|
Le@rner wrote: i m working on SDI type application ,i want to set some minimum size of application.
In your CMainFrame class, you could implement a handler for WM_GETMINMAXINFO like this:
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
int min_x = ::GetSystemMetrics(SM_CXSCREEN) / 4;
int min_y = ::GetSystemMetrics(SM_CYSCREEN) / 3;
int cx = lpMMI->ptMinTrackSize.x;
int cy = lpMMI->ptMinTrackSize.y;
lpMMI->ptMinTrackSize.x = (cx < min_x) ? min_x : cx;
lpMMI->ptMinTrackSize.y = (cy < min_y) ? min_y : cy;
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
This example will give you a minimum of 1/4 the screen width and 1/3 the screen height. You could also use hard-coded number of pixels, although this might not scale well for different monitor sizes.
|
|
|
|
|
|
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.cy = 100;
cs.cx = 100;
return TRUE;
}
You can set your custom size with use of cs.cy and cs.cx parameter
|
|
|
|
|
Hi all,
i want to calculate time that is taken by execute a function.
i m doing it like this.
DWORD dw = ::GetTickCount();
dw = ::GetTickCount() - dw;
CString time_str;
time_str.Format("%d ms", dw);
AfxMessageBox(time_str);
is it right way to do this.
thanks in advance.
|
|
|
|
|
You can get much better resolution with the APIs QueryPerformanceCounter() and QueryPerformanceFrequency() . Use ...Counter much like you use GetTickCount, and ...Frequency to calibrate your results. Hit MSDN for more info and examples.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file.
Please suggest/provide a way to write compact binary file.
TO read this file i need to use C#.
Thanks,
Sachin
|
|
|
|
|
WinZip(3GB_Filename, 2GB_Filename); ?
Seriously, it depends on what is contained in the 3GB binary file. Is it even compressible?
If it contains lots of NULLS, for example, change the NULL bytes to a single NULL followed by a count of how many there are. A string of 10 NULLS would turn into a single NULL and a byte with the number 10 in it, saving 8 bytes.
Reading the file in, you would simply reverse the process.
1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,1,2,3,a,b,c,0,0,0,0,d,e,0,f,ff
(30 bytes)
Becomes
1,2,3,4,5,0,a,1,2,3,a,b,c,0,4,d,e,0,1,f,ff
(21 bytes)
Alternatively, implement one of the Open Source Zip and Unzip routines in your C and C# code, as appropriate.
Gary
|
|
|
|
|
check this library.
http://zlib.net/[^]
use following function from library for compress binary file.
deflateInit
deflate
deflateEnd
|
|
|
|
|
I've used (libbzip2[^]) in the past with some success at shrinking certain types of binary file. Hopefully there's some repetition in it or whatever you try isn't going to be able to do much to shrink it.
Cheers,
Ash
|
|
|
|
|
|
fatal error LNK1104: cannot open file "hid.lib"
please give me any solution.
|
|
|
|
|
Ruchira Patel wrote: fatal error LNK1104: cannot open file "hid.lib"
Check if the file mentioned in the error message("hid.lib") is present or not.
If the file is in some 3rd party libraries installed in system, give the correct path in "Additional include directories" option of your project settings.
--
"Programming is an art that fights back!"
|
|
|
|
|
rp_suman wrote: give the correct path in "Additional include directories"
This is a library file, not an include file. The folder should be mentionned in "Additional Library Directories".
|
|
|
|
|
i've actually meant library path only.. thanks for the correction..
regards
--
"Programming is an art that fights back!"
|
|
|
|
|
Make sure this file exist on your system and can be found by the compiler (it should either be in the project directory or located in one of the "Additional Library Directory" (project settings -> "Linker" -> "General" -> "Additional Library Directory").
|
|
|
|
|
Ruchira Patel wrote: please give me any solution.
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
i am working on a simple application that needs to be updated frequently, do you have an an article that discusses how an application downloads the update then install it. Like an anti virus, it downloads the update definitions then install it on its own.
lets say its an application that collects updates from a common share-point.
lets not focus on the install part, what we want to focus is on the connection and download part..
and what are the common protocol and ports used for connection?
i got some good hint from Simon Ellis's article, An AutoUpdate Trick An AutoUpdate Trick[^], but i still can't find where is the download part,
any help or guide will be much appreciated, thanks in advance
|
|
|
|
|
loid grey manuel wrote: lets say its an application that collects updates from a common share-point.
I used a repository with version information, the application checks what needs to be downloaded. After successful download, checksum verification and unpacking the updater checks modification time on a per file basis, to decide which binary really needs to be replaced. If you plan to update multiple files, make sure they will be replaced together (to avoid dependency issues).
To my knowledge there is no simple automatic update mechanism on Windows, you probably need an extra executable for: stopping your application, replacing files and restarting you application again (all should be UAC compatible for Vista/Win7).
loid grey manuel wrote: and what are the common protocol and ports used for connection?
I did all network communication via HTTP, this means repository and downloads are on a web server.
Hope it helps.
|
|
|
|
|
Yup, it was a good hint for me, I've started reading books regarding your suggestions. since I don't have a personally owned database repository at least yet, and i only use free web hosting sites to store some of my files that i needed to access often.
thanks for the headstart, appreciate it.
but if you have a sample code or application for me to review the code, it would be easier.
thanks again,
|
|
|
|
|
If I use RegLoadKey() to load registry data from a hive, does the newly loaded data exist at the same time as the previously loaded data?
OR, does the previous data disappear, and only the new data exists under the predefined key?
For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
|
|
|
|
|
Richard Andrew x64 wrote: For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
Yes, unless you overwrite or delete it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks, that solves a big problem.
|
|
|
|
|