|
You have a pointer to a CA object, so use the -> operator to access the CA members:
int n = instance->m_member;
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I want to get the member's pointer, not its value.
|
|
|
|
|
|
John M. Drescher already gave you the correct answer.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Thanks. I had no clue how my answer could be wrong...
John
|
|
|
|
|
What do you mean by the members pointer??? The members address???? A pointer to m_member???
instance->m_member; will get the value.
int* xyz = &(instance->m_member); will give a pointer to m_member.
&(instance->m_member); is the address of m_member in your instance of CA.
Regards,
Brian Dela
|
|
|
|
|
Yeah, thank you!
Once a time I uesed "&(instance.m_member)" as a reference to the member.
As a result it was wrong(instance is an object). Then I replaced it with "(int *)instance.m_member", compiling is ok.
Maybe something else had been wrong.
Thank you again!
|
|
|
|
|
Your welcome.
Regards,
Brian Dela
|
|
|
|
|
I'm using the CreateFontDirect and trying to set the Point size of the height of the font and then display it. I'm using a map mode of MM_LOMETRIC, but the size is not the same as word diplays it. It works fine if the map mode is MM_TEXT.
Thanks
|
|
|
|
|
I need to create a program that will keep a list of folders synchronized, on-demand, between a number (10+) of computers on the internet. At a function call, I need a computer to be able to connect to the other computers and find and download the latest version of a specific folder. It also needs to use as little bandwidth and CPU as possible, because the computers with be also running game servers (this progam will interface somewhat with the game server, also).
Now, how should I go about doing that? I have zero experience in any network programming, but with all the articles here, I don't think it would take me too long to learn. Currently, I'm considering having a small http server and a http file download client on each computer, since that seems the simplest.
Thanks!
|
|
|
|
|
One soluton is winsock. Design your own server/client for custom system file synchronization.
Kuphryn
|
|
|
|
|
|
What's wrong with this function i used to find text in an edit control? I don't understand, it should work:
//CFindReplaceDialog FindDlg pre-defined
if (FindDlg->FindNext())
{
CString data;
GetDlgItemText(IDD_EDIT, data);
int FindIndex = data.Find(_T(FindDlg->GetFindString()), FindStart);//int FindStart global variable
if (FindIndex > -1)
{
FindStart = FindIndex + FindDlg->GetFindString().GetLength();
CEdit *edit = (CEdit *) GetDlgItem(IDD_EDIT);
MessageBox("testing...");
edit->SetSel(FindIndex, FindStart, FALSE);
}
else
{
MessageBox("The text you entered was not found.", "Text not found", MB_ICONINFORMATION);
}
}
What could be wrong with this code?
-- Steve
|
|
|
|
|
Make sure that FindStart has a valid value in it (set it to 0 or -1 and see if that helps).
The line
int FindIndex = data.Find(_T(FindDlg->GetFindString()), FindStart);
doesn't need the _T() (_T() is only used for string literals), but it won't make a difference unless you're compiling for unicode:
int FindIndex = data.Find(FindDlg->GetFindString(), FindStart);
Step through the code one line at a time and see what all your variables are after each statement. The code logic looks fine, so it should work.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
It should work, and the toolbar responds that something is selected, but there is no selection and the edit control refuses to accept any messages. The cut, copy, and paste features in my program refuse to work after a search. I've never seen this problem before.
-- Steve
|
|
|
|
|
Well,
while working on a class i am facing a really bad problem! well, i just cant get it!
i just run the following code
<br />
BOOL COpenGLWindow::CreateOpenGLWindow(RECT Rect,char* WindowCaption,bool Fullscreen,int Bits,UINT ExStyle,UINT Style,HWND Parent)<br />
{<br />
WNDCLASS WndClass;<br />
WndClass.style=CS_VREDRAW|CS_HREDRAW|CS_OWNDC;<br />
WndClass.lpfnWndProc=OpenGLWndProc;<br />
WndClass.cbClsExtra=0;<br />
WndClass.cbWndExtra=0;<br />
WndClass.hInstance=GetInstHandle();<br />
WndClass.hIcon=::LoadIcon(NULL,IDI_WINLOGO);<br />
WndClass.hCursor=::LoadCursor(NULL,IDC_ARROW);<br />
WndClass.hbrBackground=0;<br />
WndClass.lpszMenuName=0;<br />
WndClass.lpszClassName="OpenGLClass";<br />
if(!RegisterClass(&WndClass))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
bool ShowWnd=(Style&WS_VISIBLE);<br />
Style|=~WS_VISIBLE;<br />
if(!(hWnd=CreateWindowEx(ExStyle,"OpenGLClass",WindowCaption,Style,Rect.left,Rect.top,Rect.right-Rect.left,Rect.bottom-Rect.top,Parent,(HMENU)NULL,GetInstHandle(),NULL)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!(hDC=GetDC()))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
PIXELFORMATDESCRIPTOR pfd=<br />
{<br />
sizeof(PIXELFORMATDESCRIPTOR),<br />
1,<br />
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,<br />
PFD_TYPE_RGBA,<br />
Bits,<br />
0,0,0,0,0,0,0,0,0,0,0,0,0,<br />
24,<br />
0,0,0,0,0,0,0<br />
};<br />
int PixelFormat;<br />
if(!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!SetPixelFormat(hDC,PixelFormat,&pfd))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!(hRC=wglCreateContext(hDC)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!wglMakeCurrent(hDC,hRC))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(ShowWnd)<br />
{<br />
ShowWindow(hWnd,SW_SHOW);<br />
SetForegroundWindow(hWnd);<br />
SetFocus(hWnd);<br />
}<br />
return TRUE;<br />
}<br />
and the call to CreateWindowEx Failes ! GetLastError() prints INvalid Window Handle.?!?!?!?
well the call bieing made to this function is as follows:
<br />
CreateOpenGLWindow(Rect,"Mine",false,16,WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,WS_POPUPWINDOW,NULL);<br />
WEll i m in serious trouble so please help as soon as possible!
shoaib.
Doesn't Window Really Sucks!
|
|
|
|
|
Hi
My SDI program uses a CFormView derived class as View.I would like to know how i could change the view.What I mean is that when I click a button or a menu bar then I should be able to change the default view(which is a dialog) to another view(another dialog).Please Help
God is Love
|
|
|
|
|
here is the code using which u can chnage the view dynamically. i am assuming that u want the same Docuemnt to be associated with all views.
<br />
<br />
#define FIRST_VIEW 1<br />
#define SECOND_VIEW 2<br />
#define THIRD_VIEW 3<br />
<br />
<br />
void SelectView(UINT ViewID)<br />
{<br />
<br />
CView* pOld=GetActiveView();<br />
<br />
CView* pNew=(CView*) GetDlgItem(ViewID);<br />
<br />
if(pNew==NULL)<br />
{<br />
switch(ViewID)<br />
{<br />
case SECOND_VIEW:<br />
pNew=(CView*) new CSecondViews;<br />
break;<br />
<br />
case THIRD_VIEW:<br />
pNew=(CView*) new CThirdView;<br />
break;<br />
default:<br />
<br />
AfxMessageBox("Invalid ID");<br />
}<br />
<br />
<br />
<br />
<br />
CCreateContext context;<br />
context.m_pCurrentDoc=pOld->GetDocument();<br />
<br />
pNew->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,ViewID,&context);<br />
pNew->OnInitialUpdate();<br />
<br />
}<br />
<br />
SetActiveView(pNew);<br />
pOld->ShowWindow(SW_HIDE);<br />
pNew->ShowWindow(SW_SHOW);<br />
pOld->SetDlgCtrlID(m_CurrentViewID);<br />
pNew->SetDlgCtrlID(AFX_IDW_PANE_FIRST);<br />
m_CurrentViewID=ViewID;<br />
<br />
CDBase1Doc* pDoc=(CDBase1Doc*)GetActiveDocument ();<br />
pDoc->AddView(pNew);<br />
pDoc->RemoveView(pOld);<br />
<br />
RecalcLayout();<br />
}<br />
<br />
i hope this helps!!<br />
<br />
cheers!! ;)<br />
<br />
<br />
<br />
Muhammad Shoaib Khan<br />
http:
|
|
|
|
|
hi JaisonCodeMan!!
here is the code using which u can chnage the view dynamically. i am assuming that u want the same Docuemnt to be associated with all views.
<br />
<br />
#define FIRST_VIEW 1<br />
#define SECOND_VIEW 2<br />
#define THIRD_VIEW 3<br />
<br />
<br />
void SelectView(UINT ViewID)<br />
{<br />
<br />
CView* pOld=GetActiveView();<br />
<br />
CView* pNew=(CView*) GetDlgItem(ViewID);<br />
<br />
if(pNew==NULL)<br />
{<br />
switch(ViewID)<br />
{<br />
case SECOND_VIEW:<br />
pNew=(CView*) new CSecondViews;<br />
break;<br />
<br />
case THIRD_VIEW:<br />
pNew=(CView*) new CThirdView;<br />
break;<br />
default:<br />
<br />
AfxMessageBox("Invalid ID");<br />
}<br />
<br />
<br />
<br />
<br />
CCreateContext context;<br />
context.m_pCurrentDoc=pOld->GetDocument();<br />
<br />
pNew->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,ViewID,&context);<br />
pNew->OnInitialUpdate();<br />
<br />
}<br />
<br />
SetActiveView(pNew);<br />
pOld->ShowWindow(SW_HIDE);<br />
pNew->ShowWindow(SW_SHOW);<br />
pOld->SetDlgCtrlID(m_CurrentViewID);<br />
pNew->SetDlgCtrlID(AFX_IDW_PANE_FIRST);<br />
m_CurrentViewID=ViewID;<br />
<br />
CDBase1Doc* pDoc=(CDBase1Doc*)GetActiveDocument ();<br />
pDoc->AddView(pNew);<br />
pDoc->RemoveView(pOld);<br />
<br />
RecalcLayout();<br />
}<br />
i hope this helps!!
cheers!!
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
Hi
Thnaks for the reply Actually I made a function as you ahd mentioned in the mainfrm.cpp in my project and then called that function when i click on a amenu button.But it gave me an exception.Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??Also do i have to make a seperate class for each dialog that I want to make as the view of a document.or can i call any dialog.Please help
God is Love
|
|
|
|
|
JaisonCodeMan wrote:
Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??
The function which i haveshown expects only the no of View which u want to be there.. forexample FIRST_VIEW or what so ever it is...no it is not the identifier of the dialog as mentioned in resource.h.. it isjust the constant like FIRST_VIEW or SECOND_VIEW which ihave declared myself..
JaisonCodeMan wrote:
Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??
yes u need to have seprerate class for each dialog which u want to make as view of document.
cheers
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
how i can change the title of the application ?
|
|
|
|
|
simple!! SetWindowText()
cheers
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
If you want to change the title of an application that uses the Document/view framework then you will have to override PreCreateWindow and set the style to eliminate the WS_CAPTION property otherwise MFC automatically updates the application title to the file name which can be very frustrating!
See mike dunn's C++ FAQ here[^]
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
i want to monitor for all incoming and outgoing TCP conenctions on some PC. which APIs to use?
NetMon apis?
or someone having experiecne in this plz guide me!!
Thanx
Shoaib
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|