|
There are two methods that you could consider;
1. Instead of having B push the information to A, why not have A query B for the information when it's needed?
2. Use a proxy class. Thus, B and A will know about C, and B will use C to pass information to A. This is similar to the observer pattern (I think?) - there's a good articleon this site about the observer pattern but I can't remember exactly where now.
--
Andrew.
|
|
|
|
|
How can i make a taskbar in my app?
|
|
|
|
|
|
I mean a taskbar in the app 'coz when i minimize my dialogs don't keep a little window, and stay in a bar just like mIRC and other programs.
|
|
|
|
|
I have two seperate classes for two different dialogs in MFC. Now i want to acces the variables of one dialog in the code of the other class of the other dialog. How do i do this?
Thanx
Kuniva
Want, take, have.
|
|
|
|
|
The easiest way is to declare the variables as public members of the class and then access them in the usual c++ way,
void CDialog1::Test()
{
CDialog2 dlg;
dlg.m_bTestFlag = TRUE;
int nRet = dlg.DoModal();
if(nRet == IDOK)
{
BOOL bTest = dlg.m_bTestFlag;
}
}
|
|
|
|
|
How to find a string in a file?
Are there any VC functions that I can use directly?
Can you help?
Thanks,
Maer
|
|
|
|
|
If your file is a text file which I assume it is, try this...
CStdioFile file;
if (!file.Open("c:\\file.txt", CFile::modeRead))
return;
CString str;
while (file.ReadString(str))
{
if (str.Find("Search String) != -1)
{
TRACE("Found it!");
}
}
Normski - Professional Windows Programmer
|
|
|
|
|
Hi, Normski!
Thanks for your reply! It is the one I am looking for!
Have a nice weekend!
Maer
|
|
|
|
|
and you my friend!
Normski - Professional Windows Programmer
|
|
|
|
|
Thanks pal!
- My weekend is not as good as yours. My girl is in another city. 200KMs away. We just chat throught the net. ^__^
Regards,
Maer
|
|
|
|
|
Hi,
What I want, is to pass a function which is a member of one object into the contructor of a new object it declares. So the new object can then call it.
Keep getting errors along the lines of:
error C2664: '__thiscall CTest::CTest(void (__cdecl *)(char *))' : cannot convert parameter 1 from 'void (char *)' to 'void (__cdecl *)(char *)'
Can Anyone offer Any Advice, it work if i declare the function as a static.
Guess it's a c++/c isssue. The function prototype is for a standard c function where i want it to be for a class memeber function
Or is this the sort of thing that should be done through some Object Orientated Programming principle.
Thanks, Much Appreciated
Richard Jackson
|
|
|
|
|
Yes, you've pretty much got it - the non-obvious part is the passing of the implicit this pointer to member functions, which alters the function signature of those functions.
Filter on thiscall in this forum for more info. There's also a bit in the FAQ on using member fns as C (Windows) callbacks.
|
|
|
|
|
Hi,
in MFC using CSocket or CAsyncSocket following approach can set communication between a client socket and a Connecting socket on server side.
ListeningSocket.Accept ( ConnectingSocket );
Problem, How will multiple clients be implemented?
I have the clue that Link List, Array, Threads might be used for creating multiple connections with multiple clients.
like ListenSock.Accept ( ConnectSock[i] );
BUT how will the messages be handeled. How will one connecting socket differentiate form otherones message.
PLZ HELP !!!!!
RawCoder
|
|
|
|
|
I would strongly recommend NOT using the MFC implementation wrappers for sockets.
The best and *orthodox* way to to use raw sockets WSAEvent etc.
A very good book to but describing the programming of sockets for windows is
"Winsock 2.0" - By Lewis Napper.
|
|
|
|
|
I really need to do it in MFC due to time constraint.
RawCoder
|
|
|
|
|
Hello, the codegurus around the world.
First, you had better understand the concept of TCP/IP.
Server idnetifies the client with IP address and the port number.
This means that the client machine is assigned to the different IP address,
so server can understand the different client with IP address.
So, you may need the other code to restore IP addresses with the current access to the server, and differntiate the incoming socket with IP address.
(I think that this works, but I never implement this level of code. )
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
as far as i know, what can be done is for each client spawn a thread and all the window messages will be handled in that thread. so by this way multiple clients can be done. Sure u can do this using MFC. u can get a lot of source code in internet. may be have a look at www.naughter.com
|
|
|
|
|
"The C++ Programming Language" or "C++ Primer" and why?
|
|
|
|
|
Both,
The primer is elegant in its simplicity describing C++, after you got over the learning curve, "The C++ programming languauge" become your bible, and is much more detailed.
|
|
|
|
|
is there any support for c++ in Linux,
I just want to develop some word pad kind of stuff in c++ for Linux.....
can you give me any info about it....
Gaurav Lambole
webdunia.com (India) pvt.ltd.
|
|
|
|
|
Yes, gcc (Gnu Compiler Collection) contains a very good implementation of C++. It is included in all complete Linux distributions, but it might not be installed by default. There are also various GUI front ends to the compiler, e.g. KDevelop.
|
|
|
|
|
I have to give a data tip on every record(each recod contains three points) on mygraph.For this i am creating
Button controls for every point in for loop as like
MyFuntion(){
for(firstrecord,somerecords(nearly25),lastrecord)
{
CButton *pCon=new CButton;//start point
CButton *pCon1=new CButton;//peak point
CButton *pCon2=new CButton;//end point
pCon.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
pCon1.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
pCon2.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
m_datatip.AddTip(Text,pCon,Number);
m_datatip.AddTip(Text,pCon1,Number);
m_datatip.AddTip(Text,pCon2,Number);
}
}
I am calling this function from OnPaint.
For very first this code is working exactly.When ever
i am calling this function next time the controls not destroying.
I used "delete [] control" ,"delete control" in various places in my function and i didn't get the solution.
Please help me ,
Where can I delete these created controls for callling the Myfunction next time.
|
|
|
|
|
In your header...
typedef CList<cbutton*, cbutton*=""> ButtonList;
class CYourDialog or CWindow.....
{
ButtonList m_listButtons;
}
and when you create the buttons in your cpp implementation file...
m_listButtons.AddTail(pCon1)
m_listButtons.AddTail(pCon2)
... etc
and when your ready to delete the buttons, preferrable as the window/dialog is closing..
while (!m_listButtons.IsEmpty())
delete m_listButtons.RemoveTail();
Normski - Windows Professional Programmer
|
|
|
|
|
Thank you for your Information.
I used this code in my project ,but i didn't detroy all my created buttons.
I am using like this...
MyFunction()
{
CButton *pCon;
for(int i=0;i<15;i++)
{
pCon=new CButton;
pCon->create(_TEXT(""),WS_VISIBLE,CRect(),this,i);
m_buttonlist.AddTail(pCon);
}
//
//my remaining code
//
while(!m_buttonlist.ISEmpty())
{
m_buttonlist.RemoveTail();
pCon->DestroyWindow();
}
In the above attempt the last created button only destroyed.
How can destroy all the created buttons in the for loop;
please help me.
anju
|
|
|
|