|
You can get a pointer to the document class using the GetDocument() member function of the CView class (it returns a CDocument*).
Using this pointer you can manipulate the member variables of the CDocument class, execute its member functions, etc...
If you have allocated an array/linked-list in the CView class, I would simply pass a pointer to it to the CDocument class, so you don't have to copy/transmit everything. If it's a member structure, it should be public.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
"If you have allocated an array/linked-list in the CView class, I would simply
pass a pointer to it to the CDocument class, so you don't have to copy/transmit
everything. If it's a member structure, it should be public."
Correct, the linked list is part of the CView class, but how do i pass the pointer, i mean i have these classes:
CList
CView
CDoc
CList is part of CView (and its public)
What must be written in the Serialize function of CDoc?.
Fernando Jose Martinez Mendoza
Bucaramanga - Colombia
|
|
|
|
|
Your view class should not be the "owner" of the list. The list should belong to the document class, with the view class simply display the contents.
I have a similar project except that I have an array in the document class. I save it via:
class CMyDoc : public CDocument
{
private:
CDWordArray m_arrAddresses;
};
void CMyDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
m_arrAddresses.Serialize(ar);
}
|
|
|
|
|
I think its no nescesary that the CDoc class owns the class and the View class can be the "owner" as you say
Fernando Jose Martinez Mendoza
Bucaramanga - Colombia
|
|
|
|
|
Syntactically you are correct. In practice, however, it's a bad idea. Good luck.
|
|
|
|
|
How can I change the tab stop order for the controls in a dialog after the dialog is displayed?
Thanks in advance.
|
|
|
|
|
You can't, unless you're building the dialog template dynamically. The tab order of the controls is determined by their order in the dialog template. You can see this by editing the .rc file, and shuffling the controls around. Creating the template dynamically is a lot of work. Why do you want to change the tab order?
Best wishes,
Hans
|
|
|
|
|
Thank you for replying so fast. actually, I want to insert an own control into the dialog. I create this control in OnCreate. I hope the user can use "tab" to go through all the controls.
for example, there are two buttons in the dialog, call A and B. now I create an own control, I hope to set its tab stop order between A and B. Then when user presses "tab", the focus will go to A, own control, B, and go back to A.
Thanks again.
|
|
|
|
|
You would use CWnd::SetWindowPos() for each of the controls you wanted to alter.
|
|
|
|
|
HBITMAP hBitmaps = ::LoadBitmap(_Module.m_hInstResource, MAKEINTRESOURCE(IDB_MM_COPYMENU));
::AppendMenu(hMenuTrackPopup, MF_BITMAP , ID_MM_COPYMENU, (PTSTR) (LONG) (hBitmaps ));
One can use either this OR
::AppendMenu(hMenuTrackPopup, MF_BITMAP , ID_MM_COPYMENU, (PTSTR) (LONG) (TEXT("Test")));
I can either display either bitmap or display text. Is there any way I can show both Bitmap and display the text on the same Menu Item?
Similar to the the menus we see in Microsoft Word.
Pls. advise.
Thanks in advance.
|
|
|
|
|
Dear all,
I have two functions:
[code]
a) Member* get_member(Book* book);
b)Book* get_book(Member* member);
[/code]
The implementation code for the function prototypes is:
a)
[code]
template<class Book,class Member>
Member* AssociationList<Book,Member>::get_member(Book* book)
{
Member* member=0;
bool searching=true;
int index=0;
while(searching)
{
if (this->association_list[index])
if (this->association_list[index]->linked_book() ==book)
{
member=this->association_list[index]->linked_member();
searching=false;
}
else
index++;
else
index++;
if (searching && (index == LIST_SIZE))
{
searching=false;
}
}
return member;
}
[/code]
b)
[code]
template<class Book,class Member>
Book* AssociationList<Book,Member>::get_book(Member* member)
{
Book* book=0;
bool searching=true;
int index=0;
while(searching)
{
if (this->association_list[index])
if (this->association_list[index]->linked_member()==member)
{
book=this->association_list[index]->linked_book();
searching=false;
}
else
index++;
else
index++;
if (searching && (index == LIST_SIZE))
{
searching = false;
}
}
return book;
}
[/code]
All I want to do is use one generic function for the two, so that from the main.cpp:
[code]
void main()
{
List<Member>member1;
List<Book>book1;
char menuChoice;
do
{
cin>>menuChoice;
switch(menuChoice)
{
case '1': cout<<'\n';
book1.addElement("Books");
break;
case '2': cout<<'\n';
break;
case '3': cout<<'\n';
book1.displayElement("Books");
break;
case '4': cout<<'\n';
/*member1.addElement("Member");*/
break;
case '5': cout<<'\n';
break;
case '6': cout<<'\n';
/*member1.displayElement("Member");*/
break;
case '7': cout<<'\n';
//book1.borrowElement();
break;
case '8': cout<<'\n';
//book1.returnElement();
break;
default: cout<<'\n';
cout<<"Invalid Selection\n";
}
}while(menuChoice != '0' && !cin.eof());
}
[/code]
...to call each one and dispaly either the books from a book array or the members from a member array.
The'display' implementation code is:
[code]
template<class Object>
void List<Object>::displayElement(char* type)
{
if (num_elements == 0)
cout<<"No "<<type<<" is found in the "<<type<<" array.\n";
else
for(int element=0; element<this->num_elements; element++)
{
cout<<'\n';
this->element_list[element]->display(association_list.get_member(element_list[element]));
}
}
[/code]
But I'm having some errors trying to use
[code]
template<class R,class P>
R* get_member(P* pArg); instead of using the a,b function prototypes. The 'generic' function that I use and causes the problems is:
template<class R,class P>
R* AssociationList<Book,Member>::get_member(P* pArg)
{
R* member=0;
bool searching=true;
int index=0;
while(searching)
{
if (this->association_list[index])
if (this->association_list[index]->linked_book()==book)
{
member=this->association_list[index]->linked_member();
searching=false;
}
else
index++;
else
index++;
if (searching && (index == LIST_SIZE))
{
searching=false;
}
}
return member;
}
[/code]
The errors are:
[code]
'AssociationList<class Book, class Member>::get_member':unable to resolve function overload
and the second one is:
template definitions cannot nest(??)
[/code]
Could someone help me?
Regards,
grscot
|
|
|
|
|
Hello,
I am using VC++ 6.0. I want to convert a user defined object to the VARIANT type. I am not an expert in using variants. In c++ code it means:
function_takeVARIANT(VARIANT var);
function_do_something()
{
ClassA objA;
VARIANT varA;
....//Conversion here that would do varA=objA
function_takeVARIANT(varA);
}
function_takeVARIANT is a COM server's method and it uses an object of type ClassA. Is there anybody who can help me?
Thans a lot
Ahmad
Ahmad
|
|
|
|
|
Is there a C# file globbing library out there for MS Visual C 98? Or even one that can be easily tweaked to work with C#?
Any help is appreciated.
|
|
|
|
|
Hello
I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes.
The event is used to signal my workerthread when some new data should be sent.
In the workerthread I wait for some diffrent events:
hEvents[0] = pTP->hStopEvent;
hEvents[1] = pTP->hNewDataEvent;
hEvents[2] = osWriter.hEvent;
hEvents[3] = osReader.hEvent;
hEvents[4] = hDoReadEvent;
pTP is a point to a struct that is passed to the thread when I create it.
My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help.
The class is a socket communication class..
|
|
|
|
|
What do you mean "only detects that signal state randomly?" WaitForMultipleObject signals "Either any one or all of the specified objects are in the signaled state" according to MSDN.
Kuphryn
|
|
|
|
|
WaitForMultipleObjects wait for any of the events to get signalled.
But it only works sometimes when I signals the hNewDataEvent, i want to know why.
The event is created with the GUI thread and is passed to the workerthread when I create it.
|
|
|
|
|
It still would not become signaled even when you sign one or other events? Make sure the other handles are valid.
Kuphryn
|
|
|
|
|
kuphryn wrote:
It still would not become signaled even when you sign one or other events? Make sure the other handles are valid.
well.. That was the first thing I checked. It's valid alright.
|
|
|
|
|
so you have something like the below snippet?
ret = WaitForMultipleObject( 5, hEvents, FALSE, INFINITE );
if (ret == (WAIT_OBJECT_0 + 1)) //dosomething
the key points here are: 1) passing FALSE so that it doesn't have to wait for all objects 2) using INFINITE so that it blocks until an event is signalled and won't timeout, and 3) correctly determining which has become signalled. Since you didn't provide any code I can't really say what's the problem.
Joel Lucsy
|
|
|
|
|
I've solved it. I had named my event and that f***ed everything up.
|
|
|
|
|
Hi All,
I want to know if there is any mechanism for authentication of two code modules.In case the authentication fails, then the application should terminate. The authentication should be 2-way i.e. client knows that correct server is executing it and server knows that it is being executed by the correct client.
Some ideas or some existing methods on this would be helpful.
Thanks,
ITMan.
|
|
|
|
|
u have to think something like this
Client and Server knows a secret key
on connection client send a random public key
Server does the same
The client append the public key sent by the server to his private key and do an MD5 hash
The server does the same with the public key sent by the client and his private key
Then the client send the MD5 hash resulted so the server can know if the MD5 is correct by doing the same using the private and the public that the server used
The Client can do the same for the server
And if something appears wrong any side can cut the connection
Hope this helps
Any question
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I can use :
TCHAR someString[256];
someFunction(someString);
or
CString someString;
someFunction(someString.GetBuffer(256));
someString.ReleaseBuffer
Besides that fact that after the call, I still can append and modify the CString, without the need to mallocing/remallocing the string, is there an advantage of using one or the other, if only to fill in someString ?
Thanks.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
The use of a TCHAR array or a CString object is totally up to you. In your example, the former comes from the stack while the latter will come from the heap.
If someFunction() can be changed to operate on a CString object rather than a char *, you can simplify things like:
CString someString;<br />
someFunction(someString);
|
|
|
|
|
The answer is, it depends. If you are always going to be using MFC, and have no need to share common functions with other non-MFC projects, then it would probably be easier to just use CString.
On the other hand, if you think you might want to reuse some code in non-MFC apps, then TCHAR is the way to go.
BTW, in your second example, most Win32 APIs take arguments of the form "LPCTSTR lpszArg" or perhaps "const TCHAR * lpszArg". The compiler is perfectly happy to pass a CString to such APIs without the need for "somString.GetBuffer()". In fact, overuse of GetBuffer() might be a sign that CStrings are not being used properly.
Best wishes,
Hans
|
|
|
|