|
LogToList(buf, (struct sockaddr_in*)&to); should be
LogToList(buf, (struct sockaddr_in*)to); (I guess.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Seems to work, thanks!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi.
I created the core program in doc/view architecture. I understand that the idea behind doc/view is one document for each view. A document could have more than one view, but a view can only display one document, period.
Let consider I have a program that deals with text and document format. For example, I can open edit text for (*.txt) and document file (*.doc). If I am correct, I would need two document classes (derived) and at least two view. Right? If yes, what is the how do I add a new document class into the program *and link* it with a *new/different* view class? I have been using the AppWizard to generate a doc/view. I have never added a new document and a view with it.
Thanks,
Kuphryn
|
|
|
|
|
hi
you add a new doctemplate in your InitInstance() function of your app class just like app wizard does for the first one:
pDocTemplate = new CMultiDocTemplate(
IDR_TXTDOCS,
RUNTIME_CLASS(CTxtDoc),
RUNTIME_CLASS(CTxtFrame),
RUNTIME_CLASS(CTxtView));
m_pTxtTemplate = pDocTemplate;
AddDocTemplate(pDocTemplate);
then you can create new docs/views of the reqd type in response to the user doing whatever
brief i know but i quit smoking 6 days ago so forgive me
*gnash gnash gnash*
---
"all's fair in love and war but in love there is no geneva convention"
|
|
|
|
|
lauren wrote:
brief i know but i quit smoking 6 days ago so forgive me
*gnash gnash gnash*
You have my admiration for doing this (but not my undying love - even though I have seen your pic ). I hope it goes well. Be strong!
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Thanks. I want to be sure I have understand it.
To make everything clear, I am using doc/view *single* document. I am using single document because at anytime in the program, one one document is active. To my understanding, multiple document means the user can work with multiple documents at one time similar to how the user can open, view, and edit more than one images in Photoshop.
Anyways, here is the default core document template straight from a freshly generated MFC application:
-----
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMultiDocDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMultiDocView));
AddDocTemplate(pDocTemplate);
-----
I added a *two* new classes. One was derived from CDocument. The second was derived from CEditView The name of the class was "CMultiDocAct1."
New class: CMultiDocAct1Doc (derived from CDocument)
New class: CMultiDocAct1View (derived from CEditView)
Is the following correct?
-----
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMultiDocDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMultiDocView));
AddDocTemplate(pDocTemplate);
// I added the following
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMultiDocAct1Doc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMultiDocAct1View));
AddDocTemplate(pDocTemplate);
-----
All I did was added the names of the two new classes.
Lastly, I need to access the *new document* class from a view class, most likely the new view class (CMultiDocAct1View). I noticed the following code was in the original AppWizard generated view class:
-----
#ifndef _DEBUG // debug version in MultiDocView.cpp
inline CMultiDocDoc* CMultiDocView::GetDocument()
{ return (CMultiDocDoc*)m_pDocument; }
#endif
-----
Do I need to add something similar to the new view class?
Thanks,
Kuphryn
|
|
|
|
|
The line gets blurry as I consider when to use SDI and MDI. For example, in the program I am working on there are numerous "tools" that manipulate a text file. I am not certain if I should create a new document for each tool since each tool does a very specific job that manipulate the text file. That is basically what is causing my indecision.
Can you give me a very clear example of cases when you would use SDI and/or MDI?
Kuphryn
|
|
|
|
|
Hi
I have an SDI document view architecture application. It attempts to do a print preview for me, the image of the view appears far too small. I would also like the page to goto landcape.
Can anyone point be in the right direction to achieving this?
Thanks Again
Rich
|
|
|
|
|
You can setup the page as landscape like this:
void CMyApp::SetLandscapeMode()
{
PRINTDLG pd;
pd.lStructSize=(DWORD)sizeof(PRINTDLG);
BOOL bRet=GetPrinterDeviceDefaults(&pd);
if(bRet)
{
DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);
pDevMode->dmOrientation=DMORIENT_LANDSCAPE;
::GlobalUnlock(m_hDevMode);
}
}
I found this with a search through the MSDN for DMORIENT_LANDSCAPE.
As for your image size, you may need to modify your OnDraw of your view to handle cases when you are printing, or messa around with the OnPreparePrinting function to correctly setup your DC.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
How do I declare a pure virtual function that has an argument list? All the examples I've seen always seem to use the simple Shape function example.
Paul Jahans
|
|
|
|
|
It should be something like:
class CMyClass
{
virtual int MyFunction(int parameter1, int parameter2, ....) = 0 ;
} ;
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Hi, I've got some code to make a window transparent
void CMainWindow::FadeWindow(int percentage)
{
OSVERSIONINFO osvi;
GetVersionEx(&osvi);
if (osvi.dwMajorVersion>=5)
{
lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
if (!hUser32)
return;
pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes");
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
pSetLayeredWindowAttributes(*this, 0, (percentage*255)/100, LWA_ALPHA);
}
}
void CMainWindow::DisableFade()
{
OSVERSIONINFO osvi;
GetVersionEx(&osvi);
if (osvi.dwMajorVersion>=5)
{
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd,GWL_EXSTYLE) & ~WS_EX_LAYERED);
}
}
My problem is that I want the window to be transparent only while dragged (when the user clicks on the window caption); I tried overriding WM_NCLBUTTONDOWN and WM_NCLBUTTONUP, but I never receive the WM_NCLBUTTONUP, so my window stays transparent,in order to get the WM_NCLBUTTONUP, I added a SetCapture(), but then I can't drag the window any more.
Does anyone have an idea?
Thanks,
John
|
|
|
|
|
Take a look at this
http://codeguru.earthweb.com/misc/wm_nclbuttonup.html
Sorry CP!
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Thanks, looks like exactly what my problem is.
But isn't there a way to do that without any hooking procedure?
|
|
|
|
|
Take a look at the comments section at the bottom. I beleive someone posted a way that doesn't use hooks.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Damn, I didn't see the comment at the bottom of the page,
Looks far more cleaner
Thanks
|
|
|
|
|
Hi,
I wonder if, making addref and release in the Unknown pointer here is right or not ? ( or bad made...)
STDMETHODIMP CSCurveMeta::GetCloneDoc(LPUNKNOWN *XMLDoc)
{
*XMLDoc = _pXMLClonedDoc;
XMLDoc->AddRef();
return S_OK;
}
And the call:
CComQIPtr<MSXML2::IXMLDOMDocument2> _pXMLClonedDoc;
...
hr = pBsMetafile->GetCloneDoc(&pUnk);
_pXMLClonedDoc = pUnk;
pUnk->Release();
Is it wrong ?, Why yes or no ?, thanks in advance
Braulio
|
|
|
|
|
Yes and yes. Both are correct.
Here are some general rules about addref/release. A lot of it is based on the idea of borrowing an interface and owning an interface.
1. When an interface is passed to another routine, the routine need not invoke AddRef UNLESS the interface is going to be saved and later used outside of the scope of the invocation.
The idea here is that the calling routine already owns the object (by having a ref). Thus, the routine being called temporarily borrows ownership of the object while it is executing.
2. When an interface is returned to a calling routine, the routine returning the interface MUST AddRef the object. Then when the calling routine is done with the interface he should Release unless the interface is being saved for later use.
The idea in this case is that when the routine being called returns, he must either give the ownership of the object to the calling routine (by not calling AddRef) or share ownership with himself and the caller by invoking AddRef.
You code is a perfect example of point #2. The routine being called AddRefs the object to be returned. The calling routine saves a copy of the object (which due to how CComQIPtr works also does an AddRef) and then releases the returned interface.
So after all is said and done, _pXMLClonedDoc in both objects still maintain a reference.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Thanks a lot, this helps me a lot to understand all the "dark" rules of COM
Greetings
Braulio
|
|
|
|
|
It doesn't look like you're cloning your doc, but rather just adding to the ref count. You will not get a pointer to a new object, but another pointer to the original doc.
|
|
|
|
|
Thanks for the tip, but that´s what I want to do, sorry for the "Clone" name it seems a little bit strange outside it context.
What I have is an XML Doc that holds the properties, the XML Clone method, holds a copy to the original XML Doc, so I want to share that pointers with all the property pages, then I can make all the modification in the property pages, and if the user presses apply, just copy the clone to the original.
Greetings
Braulio
|
|
|
|
|
If I have an array:
double xcoord[80];
I can pass it to a function and the function can receive it as a pointer...
void AcceptArray(double* )
but how do I write the function prototype if that array were multidimensional, say -- xcoord[80][10]
|
|
|
|
|
Send it in as you would with a single dimensional array:
void AcceptArray(double *array)
but when you use it inside of your function, calculate the index that the two values would point to:
// access array[x][y],
array[(y * width) + x ]
where width is the number of columns, or x values in one row.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
okay, I have this array:
double x_coord1[80][10];
this is one of my function prototypes:
void NewCoordinates(double* xcoord1, double* ycoord1, int global_numcoord1, double* x_coord1, double* y_coord1);
and when I call on the function like so:
NewCoordinates(xcoord1, ycoord1, global_numcoord1, x_coord1, y_coord1);
I get this error:
C:\Windows\Desktop\QE2 heart program\TestGLView.cpp(460) : error C2664: 'NewCoordinates' : cannot convert parameter 4 from 'double [80][10]' to 'double *'
what am I doing wrong?
|
|
|
|
|
I am sorry, I was writing a test program to make sure that I gave you good advice, and I was distracted in the middle. When I came back to write my message to you, I assumed that the code that I got was working.
Woods13 gives the correct way to do it:
double x[][80]
or
double **x
The way that I suggested is for dynamic arrays that are declared like this:
double x[20 * 80];
then your array is one dimensional.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|