|
You have to work out how you're going to marshal (as in railway marshalling, not US law enforcement officer) your data from one process to another.
Generally you have an intermediate form that you write into your shared memory and then read out again in the other process. Say you have a class:
class A
{
public:
std::string text_;
};
You can't just use something like placement new, copy it into the shared memory and expect it to work. The string's characters could be anywhere in the source address space. One solution is to treat the shared memory like a file - you can write the characters and how many of them there are into the shared memory and read them out on the other side:
class A
{
public:
std::string text_;
void raw_memory_write( void *where );
void raw_memory_read( void *where );
};
Once you've implemented this pair you have to work out how to signal the other process that there's an object to read AND, if you want bidirectional comms, avoid writing to the same memory (you can use two blocks for this, one for each process to write into and the other to read from). While there are ways of doing this if you don't know what you're doing it can backfire horribly.
An alternative to using shared memory is to use an interprocess comms mechanism that's already out there and works. For example sockets if it has to be portable. That way all you have to worry about is reading/writing a stream of bytes from something that looks surprisingly like a file. And it's less code to write a simple sockets client/server pair than manage all the detritus around shared memory.
Cheers,
Ash
|
|
|
|
|
In my project I use many dialogbars allowing it to be docked and undocked.
I need to change the dialogbars size according to some runtime conditions and it works but,
when I dock or undock the dialog bar it restores the initial size or, when I dock another bar close to the resized bar, it consider the initial size and not the new one.
Does someone one know how to let dialogbar resize operation work properly ?
Thanks a lot !
|
|
|
|
|
How to add check mark in front of selected item in listbox in MFC..
Can anyone help me how to do this..
Thanks..
|
|
|
|
|
use
CCheckListBox .
I hope it will help you.
|
|
|
|
|
No sir, CCheckListbox will show the check box in front of every item, but I want to put check mark only in the front of selected item, rest of the items shoud not hv check box.
|
|
|
|
|
If it's your owner drawn list box with the hover effect, you can just paint the check mark in your DrawItem() method. Otherwise I'm afraid you will have to create yet another owner drawn list box class.
|
|
|
|
|
ya its my ownerdraw list box.. but I don't know how t oremove rest of check boxes on paint.
Could u please send me some sample code or some more hnt how to do..
Thanks..
|
|
|
|
|
I would probably try to derive my class from a non-checkbox control to avoid all checkboxes in the first place. Then, paint a check box and maintain the checked state myself.
Are you going to use the checkbox as a selection indicator only, or does it have any other purpose?
|
|
|
|
|
it doesn't hv any purpose. the only thing is that it make difference between the item which is already selected and the item which have the focus. I mean If "A" is already selected and my mouse is on "B" then "A" shoud hv check mark and "B " hv background color in back.
|
|
|
|
|
Well, then just paint a check mark (or whatever icon you'd like) in the beginning of the row if the item is selected.
Edit: Another way of dealing with this is to use the font and change it to be underlined when hovered. That way the selection problem goes away.
|
|
|
|
|
Hi!
I've given a multi word string. I've to display this string like taking the first letter from the first two words and the third word full. i.e If I was given "Mahendra Singh Dhoni", I've to display this as "M S Dhoni".
How to do this?
|
|
|
|
|
Tokenize the string using strtok_s with a space as the separator.
Now you will get the three words separately from which you can take the first character for the first 2 words.
|
|
|
|
|
If you're using C++ then a stringstream will do the trick for you:
#include <string>
#include <sstream>
int main()
{
std::string full_name( "Ashley Christopher Munday" );
std::istringstream in_str( full_name );
std::string first_name, second_name, surname;
in_str >> first_name >> second_name >> surname;
std::cout << first_name[ 0 ] << ". " << second_name[ 0 ] << ". " << surname << std::endl;
}
It's potentially less efficient than superman's method above but you don't have to sod about with pointers and overwriting static buffers.
Cheers,
Ash
Edit 'cause I confused two members I was referring to, sorry!
|
|
|
|
|
Hi All,
I was going through IBM's notes on C++ . Get confused by following sentences
"References and pointers cannot be used on constructors and destructors because their addresses cannot be taken "
Can anyone clarify this..?
|
|
|
|
|
What this means is that you cannot take the address of a constructor to assign to a pointer just like you would do with a normal method.
class A
{
public:
A(){}
void One() {}
};
int main()
{
void (A::*pfn)() = &A::One;
void (A::*pfn)() = &A::A;
return 0;
}
|
|
|
|
|
Great...!!!!!!
Thanks a lot << Superman >>>
|
|
|
|
|
Hi sir.
I am trying to change the Button caption
For example :
If the button caption is "Pause"
IOf i click that i am changing the caption as "Continue".
OnButtonClick(){
CButton* pMyButton = (CButton*) GetDlgItem(IDC_MYBUTTONIDC);
pMyButton->SetWindowText("Continue");
}
Now suppose if again i clicked on Continue Button.i
i want to make it as a "Pause" and viceversa
How can i do that.
Any idea will be helpful
Thanks
Raj
|
|
|
|
|
Add a BN_CLICKED handler for the button click.
Inside the function do this -
pMyButton->GetWindowText(cstring);
if (cstring == _T("Continue"))
pMyButton->SetWindowText("Pause");
else
pMyButton->SetWindowText("Continue");
|
|
|
|
|
«_Superman_» wrote: if (cstring == _T("Continue"))
Steve
|
|
|
|
|
CString cstring;
.
.
if (cstring == _T("Continue"))
|
|
|
|
|
I was objecting to the string comparison. I'd prefer to use a flag because:
- Efficiency.
- Maintainability: it will not break if the text on the button is changed and the code not updated.
- i18n.
Steve
|
|
|
|
|
Oh! Of course.
|
|
|
|
|
Hi sir,
I have some database tables which are in MS-Access.
I want to use the same tables in SQL.
Is there any easy way to import the same table in SQL
OR i have to create the same tables in SQL manually.
Thanks
Raj
|
|
|
|
|
Hi I am looking for subroutines to solve linear algebraic equations - fewer unknowns than equations. This subroutine should find the mean of each unknowns and standard deviations. This means that there will be as many as the number of sets of simultaneous equations from N to form M simultaneous equations (permutation). M- number of unknowns, N is the number of equations. N>M.
Thanks
|
|
|
|
|
mrby123 wrote: Hi I am looking for subroutines to solve linear algebraic equations - fewer unknowns than equations
If I remember well, unless some of the equations are linearly dependent, you'll get no solutions for the unknows.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|