|
Surely if n was -1 it would not evaluate to 1, but to zero, so the for loop would not loop forever?
|
|
|
|
|
In the code snippet provided by Esmo2000, when does n ever equal -1?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I hadn't seen that response yet
|
|
|
|
|
in C/C++, booleans can be reprensented the following way :
0 equals to <code>false</code>
any other values different from 0 equals to <code>true</code>
so, as (i + n) would equal to 100, it is true - until it become equals to 0...
you follow me ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
for n < 0 the loop will execute until i wraps around to abs(n)
for n == 0 the loop will never execute (i+0) == 0 == false
for n > 0 the loop will execute n times
|
|
|
|
|
Hi all///
I used a English dictionary program that can explain meaning of the word when i press ctrl + click right mouse on the word in any windows such as notepad,internet explorer,word...>>>i tried to code one same program but i didn't know how to get text of other windows as that program did.
please help me///
thanks
Here we go!!!
|
|
|
|
|
One way is to use the IAccessible interface, specifically the get_accValue() method.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi, I'm trying to write a basic Battleship game that can be played over the internet VIA a socket client/server set up.
I'm using MFC.
When the user clicks a button, it sends a message to the server where they clicked, the server then relays that on to the client. When the client receives it, they send a message back if it was a hit, or miss.
I have a thread that runs to get messages from the server, so I can have a chat running at the same time. So when the thread for receiving server messages gets a message back telling them if their shot was a hit or miss, I want to update the status of the buttons that I use for showing moves, by changing the forecolor of the button.
the code i use is --
<br />
the type of button is: CCommandButton : CWnd (Which is used as a wrapper for the ActiveX command button)<br />
CCommandButton l_Buttons[10][10];<br />
then inside of my server message thread i use the code:
<br />
l_Buttons[0][0].put_BackColor(0x0000FF);
I can put that same code into a non-threaded function and it works exactly how I want it to.
Is there any way I can fix this?
Thank you!
|
|
|
|
|
This sounds like a race condition, a common problem when multiple threads are involved.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I think I am going to end up using two ports on my program. One for server messages and one for chat. Hopefully that'll fix it.
|
|
|
|
|
i am wondering if the program is an executable file -
because file extension of the program is com (not exe).
where is help of the program (for its command)? i can not find in my computer.
includeh10
|
|
|
|
|
Yes, files having a .com extension are indeed executable. It used to be that in order to create such a file, the tiny memory model had to be used (because of the need for a single 64KB data and code segment). I'm not sure how they are created nowadays since memory models are a thing of the past.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hello,
cs.style &= ~FWS_ADDTOTITLE
i know the following code does removes untitled from title bar however can anyone explain what is happening. i am not familiar with ~ used in this way? and are we passing the address to cs.style?
thanks,
Lino
|
|
|
|
|
This code basically performs a logical operation on the cs.style variable; specifically removing the value indicated by FWS_ADDTOTITLE.
The ~, by the way, is the C++ NOT operator.
Have a read through this[^] article that explains in more detail.
I Dream of Absolute Zero
|
|
|
|
|
The value of FSW_ADDTOTITLE is 0x00008000. The ones complement (which is what the ~ symbol represents) of that is 0xffff7fff. When those bits are AND ed to whatever value cs.style currently has, the net result is that 0x00008000 is removed.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I got to use an activeX control in my VC++ project. When I import the control its wrapper class had a function as below,
void CVTSID::Connect(BSTR* RemHost, long* RemPort)
{
static BYTE parms[] = VTS_PBSTR VTS_PI4;
InvokeHelper(0x60030012, DISPATCH_METHOD, VT_EMPTY, NULL, parms, RemHost, RemPort);
}
I tried to pass the parameters as below,
CString str = "192.168.1.155";
BSTR host = str.AllocSysString();
long port = 3246;
m_dvt.Connect(&host,&port);
The function fails!
How I should pass the parameter
|
|
|
|
|
CString str = "192.168.1.155";<br />
BSTR host = str.AllocSysString();<br />
long port = 3246;<br />
m_dvt.Connect(&host,&port);
First, you are going a really long way just to create a BSTR , you can save yourself one allocation:
CComBSTR bstrHost( "192.168.1.155" );<br />
long port = 3246;<br />
m_dvt.Connect(&bstrHost,&port);
Second, what error is being returned? It looks like you are calling the method correctly, was the object created correctly?
Third, when you have to pass pointers to a COM method, it is often because you are going to get something back from the method via those pointers. COM rules state that if you pass a BSTR pointer, you own whatever BSTR comes back via that pointer, and you transfer ownership of the BSTR you sent, if any. CComBSTR will automatically deallocate the BSTR (either the one it created, or the one you get back) when its destructor fires.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I receive two errors,
1."Run-time error'9': Subscript out of range" from activeX control itself.
2."Application-defined or object-defined error" thrown by the application.
|
|
|
|
|
I came to know the problem is within the activeX control itself. I download the latest control and its working fine without errors.
Thank you James.
|
|
|
|
|
Hi,
I'm trying to code a program to verify the digital signature of several exe, dll,... files. The problem is that I don't have the certificate nor signature that is applied to those files, and neither I know if I need them . I've been looking to microsoft msdn CryptoAPI, but I could not get nothing clear out of the examples.
I suppose that I need to:
- extract somehow the signature or certificate from the loaded (BYTE*) file
- obtain a key form that certificate
- generate a hash value with CryptCreateHash and maybe later call CryptHashData?
- and finally call CryptVerifySignature praying for succes...
Any clues or full sources are welcome. I'm quite lost now .
Thanks in advance.
|
|
|
|
|
I'm trying to allow URL's to be dragged out of my app and into a browser. The relevant bit of code looks like this:
<br />
static COleDataSource gOleDataSource ;<br />
<br />
void CUrlDragDropTestDlg::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
HGLOBAL hGlobal = ::GlobalAlloc( GMEM_MOVEABLE , 4096+1 ) ;<br />
LPSTR pUrl = (LPSTR)::GlobalLock( hGlobal ) ;<br />
strcpy( pUrl , "http://www.test.com" ) ;<br />
::GlobalUnlock( hGlobal ) ;<br />
gOleDataSource.CacheGlobalData( RegisterClipboardFormat(CFSTR_SHELLURL) , hGlobal ) ;<br />
DROPEFFECT dropEffect = gOleDataSource.DoDragDrop( DROPEFFECT_LINK|DROPEFFECT_SCROLL ) ;<br />
<br />
CDialog::OnLButtonDown(nFlags, point);<br />
}<br />
This works fine for IE but not Mozilla/Firefox. Looking at what clipboard formats these apps use when dragging URL's *out* of them, the only one that seems to make sense is "UniformResourceLocator" i.e. the same one I'm using above. Dragging stuff *into* my app works fine, checking for this format.
However, when I try to drag my URL into Microsoft's IDataObject Viewer tool, it doesn't want to accept it so I'm guessing that I'm missing something. Anyone know what?
BTW, Opera doesn't seem to allow URL's to dragged at all Anyone know why they decided to do that?!
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
My guess is that Mozilla/FireFox does not accept the CFSTR_SHELLURL format as a target. You could try using the CFSTR_INETURL format as well. See if you can drag a link from IE to Moz/FF. If you can, see what other CF formats it exposes in the D&D object.
Do not forget that you should also make available other formats, like CF_TEXT /CF_UNICODE , so that you can interoperate easily with other applications.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
James R. Twine wrote:
My guess is that Mozilla/FireFox does not accept the CFSTR_SHELLURL format as a target.
This is really weird. You'd think Firefox would accept what it's putting out These are the clipboard formats that each browser puts out when dragging a link:
Dragging a link from IE (into my app):
UntrustedDragDrop
FileGroupDescriptor
FileGroupDescriptorW
FileContents
UniformResourceLocator
Dragging a link from Firefox (into my app):
13
FileGroupDescriptor
FileContents
UniformResourceLocator
13
13
text/_moz_htmlcontext
text/_moz_htmlinfo
text/html
HTML Format
13
1
where 13=CF_UNICODETEXT and 1=CF_TEXT.
text/_moz_htmlcontext is the HTML page, text/_moz_htmlinfo some binary data.
I then tried dragging links into IDataObject Viewer:
Dragging a link from IE into IDataObjectViewer:
- not allowed
Dragging a link from IE into IDataObjectViewer:
Unknown Clipformat
FileGroupDescriptor
FileContents
UniformResourceLocator
Unknown Clipformat
Unknown Clipformat
text/_moz_htmlcontext
text/_moz_htmlinfo
text/html
HTML Format
Unknown Clipformat
CF_TEXT
Dragging a link between the two browsers:
Dragging a link from Firefox into IE: OK
Dragging a link from IE into Firefox: not allowed
I've also tried including various combinations of different clipboard formats.
James R. Twine wrote:
You could try using the CFSTR_INETURL format as well.
I can't seem to find a definition for this constant. The only references I found on the net defined it as "UniformResourceLocator" i.e. the same as CFSTR_SHELLURL
BTW, I got a lot of the way to where I am now by reading your hyperlink article. Thanks for that!
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Well, I believe in the "when in Rome..." concept when dealing with cross-platform development. In Windows, a URL link, when dragged-and-dropped, has the format of CFSTR_SHELLURL , so that is what you use. When you wanna play in our sandbox, you follow our rules!
As such, I would be of the opinion that those issues are (serious) bugs in those apps.
If dragging from Firefox into IE actually WORKS correctly, you can figure out which format IE is accepting, and expose it yourself. I have to have enough faith in other developers that Firefox allows you do drag a link from one instance of itself to another, so there is at least one format it accepts...!
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I'm baffled at the results I got since I, too, generally trust programmers to get basic things like this right (and yes, Firefox allows drags to another instance of itself). The only format the two browsers seem to share is UniformResourceLocator but it doesn't seem to be working.
This is the point at which I give up, I think. Annoying, since I use Firefox most of the time. Sigh...
Thanks for your help.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|