|
I think the exact pattern the guy needs here is a Factory Method, which is similar to, but not the same as, Abstract Factory.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
What I am trying to do is simplify my program, I have a function in which I verify my tables are verified, the problem is that each table has it's own structure. I wanted to setup a new function where I could pass the structure value so I could validate my tables in one simple process instead of going thru this the long way (copy/paste). So I was trying to figure out a way to pass the structure along to a function, so I could play with it in my new verify function, and this is where I ran into problems...
|
|
|
|
|
This is a confusing discussion because I'm not sure that everyone knows what you understand and don't understand here ( you said you're new to VC++, so I don't intend this as an insult. Just trying to get to the core of the trouble ).
If you are having trouble understanding passing by value versus passing by reference, I'd be glad to explain it. It's pretty easy once you see what's going on.
If what you want is the ability to pass a structure (you should be using classes, by the way) that may have different member variables, then you probably need to understand virtual inheritance (which someone else mentioned) which gives you the ability to pass different inherited structures (classes) to the same function assuming they all have the same parent. I can explain this in more detail if you should desire as well.
Let me know and I'll try to help.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I am having trouble getting the tooltips to come up for on a toolbar. The toolbar is on a dialog. I create the toolbar like, with the CBRS_TOOLTIPS flag.
if(!m_wndToolBar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS) || !m_wndToolBar.LoadToolBar(IDR_TOOL_BAR))
ASSERT(FALSE);
I then handle the message
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
The OnToolTipNotify function looks like
BOOL CApply::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
strcpy(pTTT->szText, "Click Here - Test");
return TRUE;
}
It comes to the OnToolTipNotify but when the tooltip pops up it gives me a bunch of boxes and junk with no text.
Can anybody see something wrong?
Thanks
|
|
|
|
|
hi all,
does anybody know a way to access to C..Doc (or C..View) variables from ANY class in a project ?
I've tried :
// in a constructor of another class
CMtsBaseDoc* pDocument = ((CMtsBaseView*)(AfxGetApp()->m_pMainWnd))->pDoc;
// and even this one..
CMtsBaseApp* pApp = (CMtsBaseApp*)AfxGetApp();<br />
CMtsBaseDoc* pDocument = (pApp->GetMyView())->pDoc;
but nothing ! I just cannot get the right @ for my pDocument !? 'cos pDoc and pDocument should have the same @... and i get 2 different @
any help
thanx
Fred
|
|
|
|
|
CTtDoc *pDoc=(CTtDoc *)((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument();
|
|
|
|
|
Hello,
I tried using this in a DialogBar function to point back to the Document function to get some UINT values.
When calling the function from the Document, it works fine.
However, when calling it from the DialogBar using the pDoc pointer, the Document function cannot access any of the Document's members--even the debugger cannot "evaluate" the member variables. Both function and members are public in my case.
So it appears that this pointer is not a full-feature pointer....? I'm interested both in a solution to get Document function (data) from 'remote' classes such as my DialogBar AND (academically) what is going on in this case--why doesn't it work from a nuts & bolts standpoint.
Thanks!
JennyP
|
|
|
|
|
After trying the first example and it not working (see my previous post), I tried the following and it worked. I guess the first compiles, but the pointer points not to where the actual data is stored but rather an empty data structure? (Just my WAG.) It seems the "GetActiveFrame()" may be important. If someone could explain the technical reasons, I'd appreciate it. Thanks!
CTtDoc *pDoc=(CTtDoc *)((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
JennyP
|
|
|
|
|
even by doind so, i've got a descent value of pDoc but the values it holds are all set to 0 ?
i keep looking....
|
|
|
|
|
Now that I think of it, my values were zero, but I expected them to be zero. I'll have to set my values to be some non-zero value and see what happens. If they remain zero, then it's likely pointing to a new and separate instance of CDoc that was just created.... hmmm...
JennyP
|
|
|
|
|
I found that I have the exact same problem. I'm going to cludge around it by passing the other class's pointer to CDoc and doing it in reversed. It's worked for me before.
If you find a solution, I'd be VERY interested! Thanks!
JennyP
|
|
|
|
|
Actually, I found that my pDoc (attained as shown in previous messages above) DOES WORK.
I had another problem with my pDoc->Function that returned 0s.
Anyway,..... works for me.... maybe you should double check your document values? I saw the values were good in the debugger and simply was being returned incorrectly from a function.
Good luck.
JennyP
|
|
|
|
|
it's alright i found my mistake : a problem of where i declared the pDocument !
so now this part of code works fine, and i get access to the real values, all good.
PgGPS::PgGPS() : CPropertyPage(PgGPS::IDD)<br />
{<br />
pDocument = NULL;<br />
pDocument = (CMtsBaseDoc*)((CMainFrame*)AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();<br />
<br />
}
by doing so in the constructor pDocument, accessible anywhere within the class, allows you to access to all the variables and methods in C..Doc.
Fred
|
|
|
|
|
I think your applcation is a base on MDI,so you must invoke GetActiveFrame.and mine is base on SDI,so....
|
|
|
|
|
How would I go about capturing the Maximize and Minimize buttons. Basically I have two modeless dialogs, when one is minimized I want to hide the other, and when it gets restored I want to show the other dialog.
Any Suggestions?
Thanks in advance.
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
Handle WM_SYSCOMMAND .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hey,
does anyone know a way to disable the combination
of 'Alt + F4' on a different window given that i
have it's handle without using it's windowProc.
I have tried to use 'RemoveMenu' api function
to remove the close sysmenu but the 'Alt + F4'
still works.
thanks
|
|
|
|
|
hey,
I just wanted to add something to my question:
I also tried to set it's window style to the
exact window style of a form which i've created
in VB with no controlBox, and in that form the
combination 'Alt + F4' did not work. however,
setting the other window to the same window style
did not work.
How can that be?!?!
|
|
|
|
|
try adding an accelerator Alt + VK_F4 and set it to command id 0 or something
- Roman -
|
|
|
|
|
Alt+F4 will send a WM_CLOSE message to your application. You may consider handling that message.
Best regards,
Alexandru Savescu
|
|
|
|
|
Hey guys,
I got a question abotu variable passing again.
In my OnNewDocument function call, I store the filename into a CString called FileName. Then I call an UpdateAllViews.
In my OnUpdate I use this:
CDisplayDIBDoc* pDoc = (CDisplayDIBDoc*)GetDocument();
if (pDoc)
{
m_Dib.Load((LPCTSTR)pDoc->m_Filename);
InvalidateRect( NULL, TRUE );
UpdateWindow();
}
This takes the FileName and passes it in the load function so I can load my DIB.
All this said, I want to pass the same string to my new Child Window so that it's OnPaint will also load and then draw the same Image.
What I need to do is pass FileName from the Doc class to the ChildWindow class. I tried using the above code in the new ChildWindow class, but I get an error.
It says that GetDocument()is an undeclared identifier.
My question is:
How do I pass this string to the appropriate class?
Do I need a getDocument function for the ChildWIndow class? It is a CMDIChildWnd class. I look in Class Wizard and there is no GetDocument for me to "add Function". There is also no OnUpdate. SO should I create my own GetDocment or OnUpdate functions?
Thanks a lot,
Sorry for the ong winded question
NickOne
|
|
|
|
|
Doesn't GetActiveDocument work?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I don't suppose I could trouble you to show me an example of how I could use that?
Thanks,
NickOne
|
|
|
|
|
Never mind! I was being lazy, but I found good documentation. You were right, like always.
Now I'm rolling again!
Thanks so much!
NickOne
|
|
|
|
|
Boy I feel dumb today. I know I have seen an article on here that tells me how to keep a dialog as the top window, but I can't seem to find it through the search engin or my manual search. If someone could be so kind and point me to a good arctile I would be very grateful.
Here's to bad days.
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|