|
There's a couple of articles in the threads section of CP dealing with worker and UI threads; I haven't looked at them in detail, so maybe you've got something new to add Besides, the progress bar stuff can be useful, and publishing in CP is a lot of fun. Regards.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
I need convert an unsigned data type to a char *. How can I do this??
The problem is originated in ...
for(int counter=0; counter<house.length(); counter++)="" {
="" <i="">get_the_unsigned_from (house.room( counter );
convert_the_unsigned_to_char*;
append_(_char*_(_counter-1_)_,_char_*_(_counter_)
}
I'll appreciate your help!
Sp
|
|
|
|
|
well - you can simply go for a cast... or try stripping the sign bit.
--
John Clayton
|
|
|
|
|
|
Hi Everyone
I am trying to find out how I can hook 'onidle' from within an AddIn module for VC6. I know (using AfxGetApp()) that I can get to the CWnd* instance for MSDEV, but how on earth do I tell this CWnd* guy that I'd like to be called back when OnIdle() is being called?
Ideally, I would like to do :
AfxGetApp()->TellMeAllAboutOnIdleEvents(my_callback_interface);
(of course, this method don't exist!)
This could all be explained by my MFC naievity as well. Is it something to do with CCommandTarget perhaps? Well, while I continue to flex my eyes at the included MFC docs I shall hope for a reply.
Any help is massively appreciated! Thank you.
--
John Clayton
|
|
|
|
|
Hi.
I want to debug code that manages printing. However, I do not own a printer or have access to one. Is it possible to get print preview to emulate a printer? I just need the program to show an sample of what the print would looks like.
Thanks,
Kuphryn
|
|
|
|
|
Install a printer driver that manages PostScript (most, actually). Then, when printing, set the check box that reads "Print fo a file", rename the resulting output to .ps and use any utility (Ghostview, for instance) to see the results.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I previously wrote a Visual C++ app to perform digital I/O functions on a Windows9x machine. I/O timing was controlled using delay loops and watching the I/O signals on a logic analyzer. I know this is a kluge way of doing I/O timing, but I haven't been able to find any information on a nanosecond resolution timer (besides FILETIME) for a Windows based system. I've tried QueryPerformanceFrequency/Counter, but alas, not enough resolution.
All was well until my in-house app started being installed on other PC's with Win2K and XP. So now I'm back to square one. Is it a hopeless cause trying to find a nanosecond resolution timer for Windows OS's? I've done GPS timing resolution before, but that requires a GPS receiver which is overkill for what we're trying to do.
Please help!
Nifer
|
|
|
|
|
The best you can get it a 100ns resolution. Search for the "multimedia timer" in MSDN.
|
|
|
|
|
Now, I wanna ask 2 questions about CDC::DrawText(...).
As you know, besides supplying the text to be drawn, you also gotta tell the function the bounding rectangle to draw the text in.
1) If we specify the bounding rectangle to be far much more larger than the text(for e.g : CRect(10,10,600,600) to hold just the word "Xeon", in small fonts), DrawText(...) will auto-shrink and auto-size the bounding rectangle to fit the size of the text, right?
2) Is this behaviour the same on all versions of Windows? MSDN doesn't say too much about this at all.
Please and thanks a lot!
......
|
|
|
|
|
1. DT_CALCRECT will make the rect fit the size of the text drawn without any actual drawing. If you don't specify this switch, I think DrawText leaves the rect untouched.
2. Unless otherwise noted, functions tend to behave the same across OSs. I don't see any reason to think this is different for DrawText . Have you detected any anomaly?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
If you don't specify this switch, I think DrawText leaves the rect untouched.
Hi there and thanks a lot, Joaquin! But I do think that DrawText(...) do fit this rect to the overall size of the text.
I did an experiment on a dialog-based program with a grey background. I called CDC::DrawText(...) as in :
<br />
void CMyProgramDlg::OnPaint()<br />
{<br />
else<br />
{<br />
CPaintDC dc(this);<br />
dc.DrawText("I am Xeon.",CRect(10,10,1000,1000),NULL);<br />
CDialog::OnPaint();<br />
}<br />
}
And guess what? The text is drawn within a rectangle that fits the text exactly, cos' u see, the background color of the text is white, and the style is OPQAUE. And white against a grey background, we can easily see the size of the rect used to hold the text.
Joaquín M López Muñoz wrote:
. Unless otherwise noted, functions tend to behave the same across OSs. I don't see any reason to think this is different for DrawText. Have you detected any anomaly?
No.....I haven't a chance to detect any anomalies, cos' I don't have more than 1 OS to test out. But 'm always really suspicious of a same program running on different Windows OSes. I've heard that lotsof programs behave in different ways across different OSes, and that's a total headache.
......
|
|
|
|
|
Hi All - I'd love to know how I can get DevStudio VC6 to fire calls at my Addin's OnIdle() method - or at least to tell me somehow it's not doing anything and that I could do something during idle time.
Since the addin's are not allowed to run their own message pump (aka DevStudio application model is not thread safe) I can't just go ahead and slap a message queue in there with a thread to manage it.
What I've got is a socket connection to another server WITHIN MY ADDIN, and I want to be able to check whether there's any input on the socket during idle time.
I was also wondering if I could create a another thread then kinda 'post' messages across this thread boundary - but it requires that I hook something into the DevStudio message loop - which I don't know how to get hold of.
Any help is massively appreciated! Thank you.
--
John Clayton
|
|
|
|
|
Anyone know how to do this?
Spy shows the system tray as a single window (with no children) so getting the window rect for that is no problem but can I then locate where my icon is within the systray?
|
|
|
|
|
I have very strange behaviour of application. It´s transfer of data with TCP/IP. I´m using ovellaped WSARecv, WSASend. There was no problem on Windows 98, NT 4, 2000...but on XP it doesn´t work. For example, when transferring data block whom size exceed 3760 bytes, on W2000 is complete, but on XP is limited to 3760. I´m talking about tests on local machine, but on network was result similar(i´dont know exactly how many bytes was transferred).
Sorry, my English it´s not very good, but I believe you understand
|
|
|
|
|
Maybe just the XP stack has a lower MTU? Start by checking that (getsockopt with SO_MAX_MSG_SIZE).
|
|
|
|
|
Thanks but...maybe I said it wrong, I talked about connection oriented socket, not UDP.
|
|
|
|
|
Hi i tried to reduce my memory leak.I reduced that,but still only few bytes of memory leak.I checked everything,but still i cant find.Pl anybody can help.Thanks in advance.
HRESULT hr;
IXMLDOMDocument2 *pIXMLDOMDocument2=NULL;
IXMLDOMNodeList *pIXMLDOMNodeList=NULL;
IXMLDOMNode *pIXMLDOMNode=NULL,*pIXMLDOMNode1=NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap1 = NULL;
VARIANT_BOOL boolvalue;
long Tablelen;
CComVariant Tablename;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pIXMLDOMDocument2);
CComVariant varValue="testing.xml";
if (FAILED(hr))
return(hr);
if(SUCCEEDED(hr))
{
hr=pIXMLDOMDocument2->load(varValue,&boolvalue);
pIXMLDOMDocument2->selectNodes((_bstr_t)"DATABASE/TABLE[@Left]",&pIXMLDOMNodeList);
pIXMLDOMNodeList->get_length(&Tablelen);
HWND hListBox=GetDlgItem(hDlg,IDC_LIST);
pIXMLDOMNodeList->reset();
for(int i=0;i< Tablelen;i++)
{
pIXMLDOMNodeList->get_item(i,&pIXMLDOMNode);
pIXMLDOMNode->get_attributes(&pIXMLDOMNamedNodeMap1);
pIXMLDOMNode->Release();
pIXMLDOMNode=NULL;
pIXMLDOMNamedNodeMap1->getNamedItem((_bstr_t)"Name",&pIXMLDOMNode1);
pIXMLDOMNode1->get_nodeValue(&Tablename);
SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(char *)(_bstr_t)Tablename);
pIXMLDOMNode1->Release();
pIXMLDOMNode1=NULL;
pIXMLDOMNamedNodeMap1->Release();
pIXMLDOMNamedNodeMap1=NULL;
}
CHECK_AND_RELEASE(pIXMLDOMDocument2);
CHECK_AND_RELEASE(pIXMLDOMNode1);
CHECK_AND_RELEASE(pIXMLDOMNodeList);
CHECK_AND_RELEASE(pIXMLDOMNode);
CHECK_AND_RELEASE(pIXMLDOMNamedNodeMap1);
}
CoUninitialize();
|
|
|
|
|
Jesus!!! Does this code work???
<br />
(_bstr_t)"DATABASE/TABLE[@Left]"<br />
What is this? Never, never do like this. Do:
<br />
_bstr_t(OLESTR("DATABASE/TABLE[@Left]"))<br />
<br />
pIXMLDOMNode->Release();<br />
pIXMLDOMNode=NULL;<br />
It's not bad, but pIXMLDOMNode = 0 is enough.
<br />
(LPARAM)(char *)(_bstr_t)Tablename<br />
Should be:
<br />
reinterpret_cast<LPARAM>(static_cast<TCHAR*>(_bstr_t(Tablename)))<br />
Such a bad cast should be explicit.
<br />
pIXMLDOMNode->get_attributes(&pIXMLDOMNamedNodeMap1);<br />
You are working with very smart pointer. Instead, do like this:
<br />
pIXMLDOMNamedNodeMap1 = pIXMLDOMNode->attributes;<br />
What is:
<br />
CHECK_AND_RELEASE(pIXMLDOMDocument2);<br />
May be it a:
<br />
#define CHECK_AND_RELEASE(x) x->AddRef()<br />
I don't know.
Summary.
1. Never, never use c-casts (like (_bstr_t)x, (LPARAM)y, etc). They are the worst evil, unless you damn sure that you do. It's very hard to find a bug in a such code.
2. Read about _com_ptr_t. Learn how it's intended to use.
3. Avoid macros.
4. Optional, but strongly recommended. Get a Stroustrup.
|
|
|
|
|
Hello,
I have programmed a dialog based application and now i want to add a nice jpg image in the dialog.
Does someone know a simple way? Or does someone know a place where i can download a Control, which i can add to my project.
Thank you,
Willem
Sorry for my bad english..
|
|
|
|
|
This may be of some use,
http://www.codeproject.com/bitmap/cximage.asp[^]
Michael
"I've died for a living in the movies and tv.
But the hardest thing I'll ever do is watch my leading ladies,
Kiss some other guy while I'm bandaging my knee."
-- The Unknown Stuntman
|
|
|
|
|
|
hi
is there a way to copy a file to the same directory and renaming the file all in one. I've tried CFile::Copy, then rename, then copy again, but it seems a bit clumsy...
Thanks
|
|
|
|
|
Adrian2 wrote:
is there a way to copy a file to the same directory and renaming the file all in one. I've tried CFile::Copy, then rename, then copy again, but it seems a bit clumsy...
What exactly do you want to accomplish? Say you have a folder :- c:\abc. Now say you have a file one.gif. You want to copy c:\abc\one.gif to c:abc\two.gif and then rename one.gif to something else??? Is that what you want to do? If so, copy abc.gif to one.gif. Now rename abc.gif to whatever.gif! Pardon me if I misinterpreted your requirement.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|