|
i need to access the toolbar which is created in the parent window from the child window. but i m unable to do so. what should be done? can any1 pliz suggest.
thanx in advance
|
|
|
|
|
How about using GetParent() to get the parent window and then accessing the toolbar using the parent window.
« Superman »
|
|
|
|
|
Santosh M. P. wrote:
How about using GetParent() to get the parent window
well, tried getparent() but how to get access to the toolbar after that. pliz help
|
|
|
|
|
Hi there,
I want to write a simple dialog based application that should access the internet and get me a file from the server on the web.
Not only that, but I also need to send a URL back to the server to update the database residing on it.
Any ideas on how to do it ?
From what I read, they say that CWebBrowser can do that, but for some reason I couldn't find the basic interfaces to the Document through the file MSHTML.DLL as they stated in MSDN. could it be that I am using an old ver ?
Anyway, I am just starting out, so I'll be glad to hear on your perspective
Thanx, N
|
|
|
|
|
|
Hello everyone,
Does anyone know where could I find open source OMA Device Management client?
thanks in advance,
George
|
|
|
|
|
Hallo,
I wrote a class to communicate via a serial interface. To initialize the communication I firstly setup the interface and open it with CreateFile(...), then I start one thread to send data and one to receive with AfxBeginThread(...). When trying to send data in the send thread, the thread crashes invoking WriteFile(...). This doesn't happen when I send it in the initialization function! So, how is it possible to access resources like a serial interface in a thread?
Best regards
Juergen
Juergen Kordes
|
|
|
|
|
Post the code which send data, it will help us a lot.
What I do generaly when I need to do these kind of things (also a class to communicate with serial interface), is to start two thread (one for sending, one for receiving) but that runs functions from the class itself. A short example to explain (imagine the class is called CSerial):
UINT SendProc( LPVOID pParam )<br />
{<br />
CSerial* pSerial = (CSerial*)pParam;<br />
pParam->SendFunc();<br />
}<br />
<br />
void CSerial::Start()<br />
{<br />
...<br />
...<br />
AfxBeginThread(SendProc,(LPVOID)this,....);<br />
}
The SendFunc is a public function of CSerial that is running an 'infinite' loop to send data. Like that you can control when the loop has to finish by settings a member variable of the class to false.
It is a much cleaner way of doing this: your handle to the serial port is contained in the class itself. But be carrefull to encapsulate it into CriticalSection (take a look at the MSDN if you don't know what it is). Othrwise you will have some problems.
Hope this helps
|
|
|
|
|
Sorry that I didn't express myself exactly. Let me briefly explain the class I used:
class SERIAL<br />
{<br />
...<br />
protected:<br />
static UINT SendQueueThread(LPVOID x);
static UINT PortReadThread(LPVOID x);
<br />
CWinThread* m_pPortReadThread;<br />
CWinThread* m_pSendQueueThread;<br />
<br />
public:<br />
bool PortInitialize(...);
HANDLE hComPort;
int send(BYTE IDByte,unsigned char* pFirstByte,int len);<br />
<br />
...<br />
};
Within the SERIAL :: PortInitialize(...) I do the following:
bool SERIAL::PortInitialize(...)<br />
{<br />
...<br />
hComPort=CreateFile ( portName,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL );
<br />
<br />
if(hComPort==INVALID_HANDLE_VALUE)<br />
{<br />
...<br />
return false;<br />
} <br />
<br />
<br />
GetCommState(hComPort,&PortDCB);<br />
...<br />
SetCommState(hComPort,&PortDCB);<br />
<br />
GetCommTimeouts(hComPort,&CommTimeouts);<br />
...<br />
SetCommTimeouts(hComPort,&CommTimeouts);<br />
<br />
EscapeCommFunction(hComPort,SETDTR); <br />
EscapeCommFunction(hComPort,SETRTS); <br />
<br />
m_pSendQueueThread = AfxBeginThread( SendQueueThread, this );<br />
if( m_pSendQueueThread == (CWinThread*)0 )<br />
{<br />
displayWindowsError( "SERIAL::PortInitialize(...) Error starting SendQueueThread." );<br />
return( false );<br />
}<br />
else<br />
{ <br />
m_pSendQueueThread->SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL );<br />
}<br />
<br />
...<br />
}
The sendthread contains the following code fragments:
UINT SERIAL :: SendQueueThread(LPVOID lpvoid)<br />
{<br />
...<br />
SERIAL *pSerial=(SERIAL*) lpvoid;<br />
BYTE ClassID,CommandID;<br />
int len;<br />
unsigned char *data;<br />
...<br />
ClassID=pSerial->m_pMessage->GetClassID();<br />
CommandID=pSerial->m_pMessage->GetCommandID();<br />
len=pSerial->m_pMessage->GetMessageLen();<br />
data=pSerial->m_pMessage->GetMessageString();<br />
test=pSerial->send(CommandID,data,len);<br />
<br />
...<br />
}
At least, the function SERIAL::send(...) contains the following code:
int SERIAL::send(BYTE IDByte,unsigned char* pFirstByte, int len)<br />
{<br />
...<br />
<br />
DWORD dwNumBytesWritten;<br />
char* buffer;<br />
buffer = new char[100];<br />
for( int i = 0; i < 99; i++ )<br />
buffer[i] = i + 48;<br />
buffer[99] = 0;<br />
<br />
try<br />
{<br />
DWORD strLen = strlen(buffer);<br />
WriteFile(hComPort,
(void*)buffer,
(DWORD)strlen( buffer ),
&dwNumBytesWritten,
NULL);
}<br />
catch ( CException *e )<br />
{<br />
...<br />
}<br />
<br />
delete [] buffer;<br />
<br />
...<br />
}
That's all! When calling WriteFile(...) in SERIAL::send(...) the thread crashes, as mentioned before.
Thanks for your help!
Juergen Kordes
|
|
|
|
|
Ok... Maybe this is due to the fact that the handle is currently used by the other thread (for reading) and thus crashes. I'm not sure but that could be a solution.
Maybe a solution to that is use CriticalSections to be sure that write and read won't access the handle at the same time.
|
|
|
|
|
You are absolutly right, Cedric. Both threads tried to access the handle at the same time. Thanks a lot!
Juergen Kordes
|
|
|
|
|
we can't use some API functions in VC++6 such as AlphaBlend or
AnimateWindow and so on.
Please tell us how can we do.
you can sened your answer to :
mohsennowruzi@gmail.com
or to:
abolfazlk@gmail.com
thanks a lot
|
|
|
|
|
mohsen nowruzi wrote:
you can sened your answer to :
mohsennowruzi@gmail.com
or to:
abolfazlk@gmail.com
No way. If you want our help, read our site.
Anyhow, the API calls you want were written AFTER VC6 ( who still uses VC6 ? ) You need to download and install a platform SDK to be able to compile against libraries that include these newer calls.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I don't know about the SDK thing. I had the same problem before in my BugReporter[^] project, and I found that I just had to set the version number higher for WIN_IE or WINVER (can't remember which) in my stdafx.h file. Certain structs, constants, and functions are preprocessed out if your Internet Explorer and/or Windows version isn't high enough
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
AND regardless of the 'WINVER or other settings, if the VC6 header files on your syetm are 'old' enough, and plenty of them are using the riginal installation media (even with the SP5 updates), the API is not even declared in the older header files. Thus your need to downlaod the newer platform SDK libraries and header files AND define the WINVER and other definitions sufficiently high enough. It is not always sufficient to only do one or the other of the two tasks.
|
|
|
|
|
I stand corrected. However, the reason I saw it only as the #define 's is because I actually had this problem using VC7! So in my case, I already had the correct header files on my system, but the stdafx.h file that was generated when I started my project didn't add the #define 's correctly. (I'm more asking than telling) Is this correct?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Yes.
VC6 - Download newer Platform SDK and add defines.
VC7 - Just adjust the defines.
At some point, even the VC7 default installation of header files and libraries will be too old, and then it will also need the platform SDK and defines to see the newer API.
Using the recent platform SDK and proper defines, and I can build a VC6 program using all the latest Windows XP API just fine.
|
|
|
|
|
I got a example which could accomplish swap the tow object without needing the temporary object.
here it is
void inplace_swap(int *x, int *y)<br />
{<br />
*x = *x ^ *y; <br />
*y = *x ^ *y; <br />
*x = *x ^ *y; <br />
}
The result is correct, but I want to know the principle behind this '^' operator!
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
'^' is the XOR operator, which works bitwise. The result of XOR operator will have the bits ON only where the corresponding bits of the operands are different (i.e. one is ON and other is OFF) and the result will have the bit OFF if the corresponding bits of the operands are same (both ON or both OFF).
If you examine your code, you'll find that ultimately you are doing a
*x = *x ^ *y ^ *x<br />
*y = *x ^ *y ^ *y
XORing anything to itself nullifies the effect, so you are gettning
*x = *y<br />
*y = *x
Regards,
Pravin
|
|
|
|
|
I understand the basic knowledge, but I can't find the regularity!
Here's the output I generated!
(1)00000001^(2)00000010 = (3)00000011
(4)00000100^(6)00000110 = (2)00000010
(8)00001000^(7)00000111 = (15)00001111
(4)00000100^(9)00001001 = (13)00001101
(5)00000101^(7)00000111 = (2)00000010
(2)00000010^(6)00000110 = (4)00000100
(6)00000110^(1)00000001 = (7)00000111
(0)00000000^(2)00000010 = (2)00000010
(6)00000110^(8)00001000 = (14)00001110
(0)00000000^(6)00000110 = (6)00000110
It seems to me that when two operands(integer) XORed together, the outcome is the sum of them. But there are exception such as line 2 ,5 and 6. Why ???
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
YongSheng Li wrote:
when two operands(integer) XORed together, the outcome is the sum of them
No, It's not. XORing is different from SUMming. Let's take the example of your second line:
YongSheng Li wrote:
(4)00000100^(6)00000110 = (2)00000010
As I told in the previous post, the last bit in the result is OFF (as both are OFF in operands), the second last bit is ON (as the second last bit of one operand is OFF and that of the other is ON), again the 3rd last bit is OFF(as they both are ON in operands), remaining bits of the result are OFF as they are same (OFF) in both the operands.
If you apply the same logic to all your results, you'll find that there are no exceptions.
P.S. That's why "a^a" is zero, but "a+a" is not.
Regards,
Pravin
|
|
|
|
|
Hello,
I don't think that you know how the XOR works. Take a look at the following table and you'll see the problem:
-----------------------------------
| Param1 | Param2 | Result of XOR |
-----------------------------------
| true | false | true |
| true | true | false |
| false | true | true |
| false | false | false |
-----------------------------------
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Later I found out that
doing swap without the temporary object with
void inplace_swap(int *x, int *y)<br />
{<br />
*x = *x ^ *y; <br />
*y = *x ^ *y; <br />
*x = *x ^ *y; <br />
}
is exactly the same with the three statements above that were commented!
So the question is boil down to when will '^' do the subtraction and when addition!
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
Why doing such an easy operation so difficult?
Try the following:
void inplace_swap(int* pX, int *pY)
{
*x = *x + *y;
*y = *x - *y;
}
This solution is not perfect in the sense that it can cause integer overflow problems. My assembler is rusty, but you could get around this problem by substracting with carry or something..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
If I believe that I'm correct, the version with the temporary object, generates less assembler instructions than this version.
If you take a look at the generated machine code, you'll see that what you are trying to do results in less optimal code!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|