|
There are several solutions for data sharing among processes.
- Winsock
- File-Mapping
- Namepipe
I recommend file-mapping. Mapping the handle of your socket with a valid name. Search for that file-mapped on the other applications via its name.
Kuphryn
|
|
|
|
|
Suppose I have an unsigned integer variable. How can I read only bits 3 to 10 off of it?
Isaac Sasson,
Small time programmer - complainer at large!
Sonork ID 100.13704
|
|
|
|
|
do a binary and (&&) with a bitmask
i.e.
binary 0011111111000000 = 0x3FC0 (hex)
so
nResult = nNumber && 0x3FC0;
You can then use the shift operators << or >> to shift the bits if you want to strip of trailing zeros
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
BOOL IsBitOn (UINT uOriginal, UINT nBit)<br />
{<br />
uOriginal >>= nBit;
uOriginal &= 1;
return (uOriginal == 1);<br />
}
and for the concisists...
#define IsBitOn (x,n) ((x>>n)&1)<code><br />
<br />
Or if you just want to mask out the other bits,<br />
<br />
<code>uOriginal &= 0x03fc;
I hope that helped,
Iain.
|
|
|
|
|
i want to see what does the preprocesor generates how can i do that?, using vc++ 6.0
|
|
|
|
|
add /E to the compiler options. Preprocessed files will go to stdout.
Back to real work : D-22.
|
|
|
|
|
thanks.
|
|
|
|
|
Hi!
I have a MFC application that handle idle processing by overloading CWinApp::OnIdle ; for menus and dialogs, I handle the WM_ENTERIDLE in my MainFrame. But I use ShowHTMLDialog API to display HTML page, and then, I don't receive EnterIdle any more. Why ?
Thanks for any help
Regards
Emmanuel Derriey
|
|
|
|
|
i am not sure if WM_ENTERIDLE is a standard message.
if yes, u can get if from PreTranslateMessage function.
if not (it's a fuction call actually), microsoft never offers it for the class.
includeh10
|
|
|
|
|
ShowHTMLDialog shows a modal dialog box, so by definition you can't expect your app to continue to go into idle from time to time.
There's a work around for that, you have to create a separate thread, and call ShowHTMLDialog in that thread.
Back to real work : D-22.
|
|
|
|
|
Why does some write:
typedef struct {
foo bar;
} MyStruct;
whilst I write
struct MyStruct {
foo bar;
};
I know that it's possible to declare LPMyStruct in the first example.
And why the _TAGMYSTRUCT in some cases?
|
|
|
|
|
I think the fomer syntax is C-code (as opposed to C++), meant to trick some C-compilers into doing what you want.
|
|
|
|
|
it is all for C.
typedef struct ABC
{
foo bar;
} MyStruct;
i.e.
MyFunction(MyStruct ms); //C needs struct as description
similar to:
MyFunction(struct ABC ms);
it can be used by both C and C++.
includeh10
|
|
|
|
|
That was what I meant: You can use all of these forms in both C and C++, but you only NEED them in C.
|
|
|
|
|
I want to change CString data to CString data(in Hex format) and change back from CString data (in Hex format)
to CString data. So I write this below code
<br />
CString m_str = "chop][:" ;<br />
CString ivstr;<br />
StrToHexStr(m_str, ivstr); <br />
StrToHexStr function change CString data to CString data(in Hex format)which have these below detail.
<br />
void StrToHexStr(CString& strData, CString& hexstrData)<br />
{ <br />
int j;<br />
CString strtemp;<br />
<br />
hexstrData.Empty();<br />
for (j=0;j<strData.GetLength();j++){<br />
strtemp.Format("%02X",strData.GetAt(j));<br />
hexstrData+=strtemp;<br />
}<br />
}<br />
I get ivstr = "63686F705D5B3A" (from m_str = "chop][:")
Then I write program to change back from CString data (in Hex format)to CString data.
<br />
ivstr = "63686F705D5B3A"; <br />
HexStrToStr(ivstr, m_str);<br />
HexStrToStr function change CString data (in Hex format)to CString data which have these below detail.
<br />
void HexStrToStr(CString& hexstrData, CString& strData)<br />
{ <br />
int j, strlen;<br />
CString c1, c2;<br />
int temp;<br />
unsigned char ctemp;<br />
<br />
strData.Empty();<br />
<br />
for (j=0;j<hexstrData.GetLength();j+=2)<br />
{<br />
c1= hexstrData.GetAt(j);<br />
if ((c1 == 'A')||(c1 == 'B')||(c1 == 'C')||(c1 == 'D')||(c1 == 'E')||(c1 == 'F'))<br />
{<br />
ctemp = c1[0];<br />
temp = (ctemp-55)*16;<br />
}<br />
else<br />
{<br />
temp = atoi(c1)*16;<br />
}<br />
c2= hexstrData.GetAt(j+1);<br />
if ((c2 == 'A')||(c2 == 'B')||(c2 == 'C')||(c2 == 'D')||(c2 == 'E')||(c2 == 'F'))<br />
{<br />
ctemp = c2[0];<br />
temp = (ctemp-55);<br />
}<br />
else<br />
{<br />
temp += atoi(c2);<br />
}<br />
strData += temp;<br />
}<br />
}<br />
But I do not get m_str = "chop][:"
m_str is the other string
Do you know how to solve my problem?
Thank you for your reply.
|
|
|
|
|
When reversing the process, take each two Hex chars, convert them to a long (strtol base 16 ) then format it into a char, then concatenate into a string
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How can I get the coordinates of a window, relative to it's parent?
And how can I create sticky buttons on a toolbar? (Staying up/down when clicked)
Using MFC
|
|
|
|
|
Not sure about the coords part, but sticky buttons work exactly the same way as checkable menu items do
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
benjymous wrote:
Not sure about the coords part, but sticky buttons work exactly the same way as checkable menu items do
And that would be... how :p
|
|
|
|
|
Its relatively simple:
CRect GetCoordsRelativeToParent (CWnd *pCoordsOf)<br />
{<br />
CWnd *pParent = NULL;<br />
ASSERT(pCoordsOf);<br />
if (pCoordsOf != NULL)
pParent = pCoordsOf->GetParent ();<br />
<br />
CRect rcCoords;<br />
pCoordsOf->GetWindowRect (&rc);<br />
pParent->ScreenToClient (&rc);<br />
<br />
return rc;<br />
}<code><br />
<br />
I'm going of memory, so the syntax of the commands may be a little wrong, but you hopefully the idea!<br />
<br />
Iain.
|
|
|
|
|
Thanks a lot
|
|
|
|
|
Locked Ghost wrote:
And how can I create sticky buttons on a toolbar? (Staying up/down when clicked)
// where i is the button index (1,2,3,4,5,6 etc...)
m_wndToolBar.SetButtonStyle(i, TBSTYLE_CHECK);
Locked Ghost wrote:
How can I get the coordinates of a window, relative to it's parent?
CPoint point;
ClientToScreen(&point);
|
|
|
|
|
I forgot you need to handle the ON_UPDATE_COMMAND_UI ... and do a SetCheck either TRUE or FALSE to set the button down and up..
|
|
|
|
|
How can I catch an event in my application when user changes/changed language
(for instance, from En to Fr or De) in system tray area or with ALT+SHIFT?
Thanks
|
|
|
|
|
- INTRODUCTION:
I have created a derived CListCtrl class.
That class have a CEdit and a CComboBox var.
I try to instantiate them using their Create function but the this pointer is still null in the constructor of the ListCtrl.
- QUESTIONS:
When do the ListCtrl this pointer won't be null?
Which message must I handle in order to be able to use the Create functions? I mean that as in a dialog there's the OnInitDialog function, could it be possible to have something similar in a control?
- CODE:
the header file:
<br />
CEdit m_cedParametritzacio;<br />
the constructor in the cpp file:
<br />
CRect rInicialitzacio;<br />
<br />
rInicialitzacio.left = 0;<br />
rInicialitzacio.top = 0;<br />
rInicialitzacio.right = 20;<br />
rInicialitzacio.bottom = 20;<br />
<br />
int iR = this->m_cedParametritzacio.Create(ES_AUTOHSCROLL, rInicialitzacio, this, IDC_ED_PARAMETRITZACIO_LCTRL);<br />
Due to the fact that this is still NULL the function fails.
|
|
|
|