|
To add libraries to use in VC++.NET; in the solution explorer windows right click on the name of your project (under solution and before the file listing), then select properties. Then look under linker / input.
Seem like everything is a property in the new .NET Studio.
|
|
|
|
|
Thanks,
Will try this
|
|
|
|
|
could someone give me a pointer to where i might find an example of how to have a toolbar in my splitter window? I notice outlook has this type of look..
I have tried over-riding the CSplitterWnd::OnNcCreate() function, but it never gets called.. (still don't know how to over-ride a class function in .NET..)
any pointers?
-dz
|
|
|
|
|
I salute you all,
I am new on MFC and right now i am trying to make a Microsoft's paint again.
My question is; Toolbox used in that program is CReBar object or CToolBar object? If CToolBar object how can i make two column toolbar.
Thank you.
|
|
|
|
|
Hi
As I mentioned in one of my threads before I'm working on a project that displays the traffic of other applications in a seperate window. For this purspose I'm using the Microsoft "Detours" library.
Now I want to intercept the sendto() function. This is done that way:
int __stdcall MINE_sendto(SOCKET s, const char FAR * buf, int len, int flags, const struct sockaddr FAR * to, int tolen )
{
LogToList(buf, (struct sockaddr_in*)&to);
return REAL_sendto(s, buf, len, flags, to, tolen );
}
It intercepts the sendto-function, displays some interesting data into the seperate window and returns the original sendto() function. However, I can't figure out the destination IP to where the packet is about to be sent.
LogToList() is this function:
void LogToList(const char FAR * buf, struct sockaddr_in *to = NULL)
{
if(logTraffic)
{
struct sockaddr_in *dest;
dest = to;
char ip[20];
sprintf(ip,"%s:%d",inet_ntoa(dest->sin_addr),ntohs(dest->sin_port));
....(set values for buffer and IP into ListCtrl - this works)....
}
}
The buffer is displayed correct, however, the IP is always the same:
16.0.0.0:62464
What am I doing wrong?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
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.
|
|
|
|
|