|
you can do this with many ways as follows:-
1- Yourclass::OnOk()
{
// make it empty
}
2- use SetwindowHookEx function to capture Keyboard keys
and u can compare the wpararm parameter in your callback function if it =13 then Enter key has been pressed and you
can do any thing you need.
after this if broblem is found contact me on faroq_tam2004@yahoo
to send to you some source code
faroq from yemen thammar
working in thammar universty and my intersted about network and security
im programmer from 6 years ago and ihave my B.C from this universty
|
|
|
|
|
faroqtam wrote:
use SetwindowHookEx function to capture Keyboard keys
You must be kidding.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello,
I'm doing a multithreaded application that creates threads using the _beginthreadex api.
At some point I need to wait for the thread to exit (it exits normally) using the WaitForSingleObject api.
When I'm debugging , the thread function just exits normally. After the thread has exited, the <waitforsingleobject< code=""> api does not return, but still waits on the thread handle.
I'm not signalling the thread handle (which I don't think I should) and the thread has default access.
Is there anything that I should do with the thread handle before the thread exits?
Thanks in advance.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
One solution is an event.
Kuphryn
|
|
|
|
|
Yeah, but MSDN says that you can use the wait api's on thread handles created by _beginthreadex . Since that solution would be more elegant than using another event or synchronisation primitive, I prefer too use that solution...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Correct. An independent event allows for reusability. Otherwise, call _endthreadex() before returning zero.
Kuphryn
|
|
|
|
|
It's hard to say without seeing your code, but the first thing to check is that you're waiting on the thread handle, not the thread ID. The handle is the return value from _beginthreadex() (you need to cast it to HANDLE ) while the ID is returned via the last parameter of _beginthreadex() .
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Hello,
I'm certain that I'm passing the handle returned by _beginthreadex to WaitForSingleObject .
I have to say a couple a things about the thread code:
1) It's a class
2) You can post messages to the thread function
3) The thread handle cannot be changed (it's not constant, but there is no statement that modifies the variable)
4) The thread functions returns after posting a TM_EXIT message
Anyhow, here's some code:
I create the thread like this:
<br />
m_hThread = (HANDLE) _beginthreadex(NULL, 0, CThread::Run, this, 0, &m_nThreadID);<br />
<br />
if( m_hThread == 0 )<br />
{<br />
}<br />
The thread is terminated like this:
<br />
PostMessage(TM_EXIT);<br />
<br />
if( bWaitForTermination == TRUE)<br />
{<br />
switch( ::WaitForSingleObject(m_hThread, INFINITE) )<br />
{<br />
case WAIT_FAILED:<br />
{ <br />
CStdString szError = "ERROR: Waiting for thread (0x%X, ThreadID: %d) termination failed. Reason:\n";<br />
INTERNAL_LOCK();<br />
szError.Format(szError, m_hThread, m_nThreadID);<br />
<br />
GetLastErrorMessage(szError);<br />
<br />
this->SetError(szError);<br />
<br />
return TRC_UNKNOWNERROR;<br />
}<br />
case WAIT_TIMEOUT:<br />
{<br />
return TRC_WAITTIMEOUT;<br />
}<br />
}
}
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Thanks to the unit test, the problem was found. There was a litle bug in the CThread::PostMessage which caused that 1 message remains in the queue while the thread thinks it's empty...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
I need to evaluate some logic expression at runtime in C++.
Stuff like "(a OR b) AND (NOT c OR d)"
( a,b,c,d is logical values of TRUE or FALSE. ( 0 or 1) )
I search google for hours and found a lot. But nothing really useful.
Anybody got any classes , code samples , links or anything that can help me out ?
/ Mathias S.
|
|
|
|
|
I have a piece of code that implements a transparent bitmap by taking a copy of a rectangle in the dc, manipulating it and then copying it back again. Everything works fine for display DCs and even print preview. However it all goes wrong when I use a printer DC. The copying from the printer DC to a memory DC just doesn't happen. The result from BitBlt is TRUE, indicating success, but it actually does nothing. A test picture that is inserted beforehand remains intact. Perhaps it is a problem with the printer driver (Epson CX3200). GetDeviceCaps says that it implements BitBlt.
Has anyone else had a similar problem or knows of a solution?
|
|
|
|
|
try with anthor bliting functions as Dibdraw or anthor.
faroq from yemen thammar
working in thammar universty and my intersted about network and security
im programmer from 6 years ago and ihave my B.C from this universty
|
|
|
|
|
See my article "Printing tips and tricks from the trenches" in the printing section. It covers this and over topics.
If you vote me down, my score will only get lower
|
|
|
|
|
There are some very useful points in your article.
OK, so I can't use BitBlt, and I should be using a DIB drawing routine. How do I get a DIB for the picture that has already be drawn into the printer's DC?
SelectObject(hDC, (HBITMAP)NULL) returns NULL
and I can't BitBlt it to a memory DC.
|
|
|
|
|
There is a function present in the article DDBToDIB in the article sourec which can be used to convert a DDB to a DIB. You can use this to get the picture in the right format before calling StretchDIBBits
If you vote me down, my score will only get lower
|
|
|
|
|
Yes, but how do you get the DDB for printer DC. i.e what has previously been written to the printer DC.
|
|
|
|
|
I am working on a project using C and C++ on .NET. I am using existing dll's written in C++, while because of real time considerations, some of the new modules must be written in C, rather than C++. C does not recognize the statement "using namespace ...", and consequently, functions in the C++ modules cannot be found when called from the C modules. Is there another way of letting the C modules know where these functions are?
One solution is to compile the C modules with the C++ compiler. If I do this, will the resulting executables run as efficiently (with respect to execution time) as C code compiled in C, or will they run less efficiently, like C++ code compiled in C++?
Thank you so much for your help.
|
|
|
|
|
I would imagine that if you compile C modules in the C++ compiler, you'll only pay for the overhead of the bits of C++ you use ( in this case, namespaces, whose cost must be close to zero ). However, your best bet is probably to do some benchtesting and see what results you get.
Does ' on .NET' mean you're compiling managed C++ ? If so, then that's different, you will incur the cost of the .NET runtime. One idea would be to make a COM dll, so your .NET code can call non-.NET C++ code easily.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I Override The PreCreateWindow Func
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |WS_MAXIMIZEBOX|WS_MAXIMIZE;
return TRUE;
}
And I want The Restore Button To Be Disabled i Removed The WS_MAXIMIZEBOX style but the resulting window covers the task bar and i don't want that.
I just Like the size the window has when using the above settings combinations but don't want the window to be resized by cliking the restore or double clicking on the title bar
Is There any way i can catch this using the WM_WINDOWPOSCHANGING,WM_NCCALCSIZE,WM_WINDOWPOSCHANGED or WM_SIZE
|
|
|
|
|
use following code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (BaseClass::OnCreate(lpCreateStruct) == -1)
return -1;
// Do something
// Remove positions of menu
CMenu* pTopMenu = GetSystemMenu(FALSE);
if(pTopMenu != NULL)
{
pTopMenu -> RemoveMenu(SC_SIZE, MF_BYCOMMAND); //remove resizeing
pTopMenu -> RemoveMenu(SC_MOVE, MF_BYCOMMAND); //remove Moveing
pTopMenu -> RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND); //remove Maximizing
}
return 0;
}
|
|
|
|
|
I Already Done That But When Double Cliking On The Title bar The Window Restores.
|
|
|
|
|
(There's probably a thread like this one every day so... sorry!)
I'm working on a project in which I want to rely only on my own code so therefore I have to go through the pains of writing my own String class. I am a C++ programmer at beginner/intermediate level so there might be some very flagrant errors in there. This is what I have so far:
Declaration
Definition
Any suggestions would be appreciated!
|
|
|
|
|
Whilst I haven't looked at your code, I would suggest seriously considering whether it is worth writing your own string class, given that there are a million implementations of it already both in the standard C++ libraries and on the 'net. Strings are funny because they're succeptible to buffer overflow errors all over the place so if you do implement your own string class, this is something you will have to be very careful of. Alternatively, the std::string class from the STl has this all done already.
Just a suggestion...
--
Andrew.
|
|
|
|
|
Hi,
i need to get the imagenumber from a clistctrl on which i added a imagelist.
At the OnDoubleClick event i need to get the imagenumber from the selected item.
Is there any way to retrieve the number?
I want to compare like
if (imagenumber == CONST_BITMAP_FOLDER)
{
Send next command
}
thx!
|
|
|
|
|
See CListCtrl::GetItem() and LVITEM .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|