|
use the SDK version SendMessage(HWND , UINT, ...)
and use the handle for your frame window (CFrameWnd).
From there, when the message is received, route it to
the doc (call a document function, whatever).
|
|
|
|
|
I'm used to Borland, where you can just drop a tab control in the visual environment, then select each tab in turn and drop controls onto the tabs just like you do with a normal dialog. It doesn't seem possible to do this with VC++, or have I missed something? Can anyone point me in the direction of a simple guide to creating a tabbed dialog app?
Dave
Dave
|
|
|
|
|
I had used Borland once and the list of things that could not be done was too long.
Borland == Visual Basic for C++
Anyway, no you can't drop controls on the seperate tabs (at least that I'm aware of). You would have to place them in the dialog editor and then handle the change tab message to show or hide the appropriate controls.
|
|
|
|
|
|
Good point. I thought about PropertySheet/PropertyPage after I hit submit.
|
|
|
|
|
The solution described in this article doesn't use propsheets or proppages, no matter how they titled it. They just create a tab control and host child dialogs inside ('real' propsheet uses similar method). When tabs are clicked, hosted dialog is replaced by another 'page'.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello,
I want to create my mainframe with a certain size. Right now I have overridden CMainFrame::PreCreateWindow and I set the members of the CREATESTRUCT x,y,cx and cy to hardcoded values.
I would however like to do this properly, by using AdjustWindowRect(Ex) to calculate the values for me.
The whole point is I want the client area to be of zero height, like the Visual Basic development environment used to be.
I cannot make this work. Here is my code:
BOOL COptixFrmMain::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_MAXIMIZEBOX;
// cs.style &= ~WS_THICKFRAME;
// cs.style &= ~WS_SYSMENU;
/* These values are the ones I want!
cs.x = 0;
cs.y = 0;
cs.cx = 450;
cs.cy = 105;
*/
RECT rect;
SetRectEmpty(&rect);
rect.right = 450; // I want it to be 450 wide
::AdjustWindowRect(&rect,cs.style,TRUE);
cs.x = 0;
cs.y = 0;
cs.cx = rect.right - rect.left;
cs.cy = rect.bottom - rect.top;
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS, // if you need double-clicks
NULL, // no cursor (use default)
NULL, // no background brush
AfxGetApp()->LoadIcon(IDR_MAINFRAME)); // app icon
ASSERT(cs.lpszClass);
if( !SECFDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
If you look carefully, you can see that I use Objective Toolkit, and their FDI classes, but that should hardly matter in this case.
All help is appreciated!
************************
Peter Andersson
peter.andersson@dtsag.ch
|
|
|
|
|
Objective Toolkit should hardly matter. You would be surprised. We gave up on using Stingray for our projects because they had so many features we had to work around. I recently had another project that used a Stingray tree control that gave some strange runtime errors. I eventually tracked it to the fact that while I expected a NULL to be returned in some cases it was not. I took Stingray out of the picture and everything worked perfectly.
|
|
|
|
|
I think you are right. A small testprogram shows that AdjustWindowRect does not understand the StingRay tear-off menu.
However, the std MFC testprog works fine, except for not noticing the toolbar. How do I find the height of that one?
Peter
************************
Peter Andersson
peter.andersson@dtsag.ch
|
|
|
|
|
You can use the following VB Script to create a project:
Set objMSDEV = WScript.CreateObject("msdev.application")
objMSDEV.addproject "test","c:\myapp",TRUE
objMSDEV.ActiveProject.AddFile "test.cpp"objMSDEV.QuitWScript.Echo "Done"
From this I have determined that the following C++ code should also generate a project:
#include "stdafx.h"
#include <stdio.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <initguid.h>
#include <comdef.h>
#include <ObjModel\appauto.h>
#include <ObjModel\appdefs.h>
#include <ObjModel\appguid.h>
#include <ObjModel\bldauto.h>
#include <ObjModel\bldguid.h>
#include <ObjModel\blddefs.h>
#include <ObjModel\textauto.h>
#include <ObjModel\textguid.h>
#include <ObjModel\textdefs.h>
#include <ObjModel\dbgauto.h>
#include <ObjModel\dbgguid.h>
#include <ObjModel\dbgdefs.h>
IApplication *pApp;
int main(int argc, char* argv[])
{
HRESULT hr = CoInitialize(NULL);
if(FAILED(hr))
{
printf("Failed to initialize the COM libraries\n");
return FALSE;
}
hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**)&pApp);
if(FAILED(hr))
{
printf("Failed to create an instance of MSDEV\n");
CoUninitialize();
}
CComBSTR bProjectName("project");
CComBSTR bPath("c:\\myproject");
CComBSTR bType("Application");
VARIANT_BOOL bCreateDirs=VARIANT_FALSE;
pApp->AddProject(bProjectName,bPath,bType,bCreateDirs);
pApp->Quit();
pApp=NULL;
CoUninitialize();
return 0;
}
The problem is the call to add the project generates the following error:
Debug Error!
Program: test.exe
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved accross a function call.
This is usually a result of calling a function declared with one
calling convention with a function pointer declared with a different
calling convention.
Can any body tell me what I am doing wrong?
Thanks for any help you can provide.
Steve.
|
|
|
|
|
I don't see a pApp->Release() call being made. Not sure if that's the problem though....
HTH
Jignesh
|
|
|
|
|
The error comes from the call to pApp->AddProject() so I dont get far enough to make a call to pApp->Release(), but thanks for trying.
|
|
|
|
|
I think this has something to do with IDispatch vs IUnknown - IApplication is a dual interface, so I decided to try using IDispatch::Invoke instead of calling the AddProject interface directly:
#include <stdio.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <initguid.h>
#include <comdef.h>
#include <ObjModel\appauto.h>
#include <ObjModel\appdefs.h>
#include <ObjModel\appguid.h>
int main(int argc, char* argv[])
{
HRESULT hresult = CoInitialize(NULL);
if(FAILED(hresult))
{
printf("Failed to initialize the COM libraries\n");
return FALSE;
}
IUnknown FAR* punk;
IDispatch FAR* pdisp = (IDispatch FAR*)NULL;
DISPID dispid;
hresult = CoCreateInstance(CLSID_Application, NULL, CLSCTX_SERVER,
IID_IUnknown, (void FAR* FAR*)&punk);
if(FAILED(hresult))
{
printf("Failed to create an instance of MSDEV\n");
CoUninitialize();
}
hresult = punk->QueryInterface(IID_IDispatch,
(void FAR* FAR*)&pdisp);
OLECHAR FAR* szMember = L"AddProject";
hresult = pdisp->GetIDsOfNames(IID_NULL, &szMember, 1,
LOCALE_USER_DEFAULT, &dispid);
VARIANT varResult;
EXCEPINFO excepInfo;
unsigned int uArgErr;
DISPPARAMS dispparams;
dispparams.rgvarg = new VARIANT[4];
CComBSTR bstrProjectName("project");
CComBSTR bstrPath("c:\\myproject\\project");
CComBSTR bstrType("Application");
dispparams.rgvarg[0].vt = VT_BOOL;
dispparams.rgvarg[0].boolVal = VARIANT_TRUE;
dispparams.rgvarg[1].vt = VT_BSTR;
dispparams.rgvarg[1].bstrVal = bstrType;
dispparams.rgvarg[2].vt = VT_BSTR;
dispparams.rgvarg[2].bstrVal = bstrPath;
dispparams.rgvarg[3].vt = VT_BSTR;
dispparams.rgvarg[3].bstrVal = bstrProjectName;
dispparams.cArgs = 4;
dispparams.cNamedArgs = 0;
hresult = pdisp->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
&dispparams, &varResult, &excepInfo, &uArgErr);
if(DISP_E_EXCEPTION == hresult) {
_bstr_t bt(excepInfo.bstrDescription);
printf("VC Exception: %s\n", (char*)bt);
}
szMember = L"Quit";
hresult = pdisp->GetIDsOfNames(IID_NULL, &szMember, 1,
LOCALE_USER_DEFAULT, &dispid);
dispparams.cArgs = 0;
hresult = pdisp->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
&dispparams, &varResult, &excepInfo, &uArgErr);
pdisp->Release();
punk->Release();
delete [] dispparams.rgvarg;
CoUninitialize();
return 0;
}
Pretty ugly, but seems to work. The docs and samples for this are a bit lacking, and somebody stole borrowed my copy of Essential Com, so I don't know if this is the only way this can be done.
I guess the theory here is that the interface is intended to be invoked through IDispatch, and problems show up if parameters need to be passed when using AddProject directly.
Would appreciate if someone could verify or debunk said theory.
-----
"They put the COM in COMplicated"
|
|
|
|
|
Thankyou very much for the information.
|
|
|
|
|
I would suggest to use the #import statement on your typelibrary/dll and call COM by using the IApplicationPtr smart pointer that this import statement creates for you.
-Nick-
|
|
|
|
|
Ah! Good idea - actually, article Q247035 discusses both methods, but neither seems at first glance what I would call elegant.
Using #import, this is about the simplest I could come up with - please excuse the strange err handling...
#include "stdafx.h"
#include <atlbase.h>
#import "devshl.dll"
using namespace DSSharedObjects;
int main(int argc, char* argv[])
{
HRESULT hr = CoInitialize(NULL);
if(FAILED(hr)) {
_asm int 3;
}
DSSharedObjects::IApplicationPtr pIApp;
hr = pIApp.CreateInstance("MSDEV.Application");
if(FAILED(hr)){
_asm int 3;
}
_bstr_t bstrProjName("myproject");
_bstr_t bstrPath("e:\\project\\myproject");
_bstr_t bstrType("Application");
VARIANT_BOOL bCreateDirs = VARIANT_TRUE;
hr = pIApp->AddProject(bstrProjName, bstrPath, bstrType, bCreateDirs);
if(FAILED(hr)) {
_asm int 3;
}
pIApp->Quit();
return 0;
}
But it looks to me like this automation will be obsolete with VS.NET - I just started looking at beta 2 and there are no ObjModel headers, and no devshl.dll.
|
|
|
|
|
Thanks again for helping me with my problem. I managed to get this method working last night (this morning technically). I am now trying to figure out how to add source and header files to the project.
Steve.
|
|
|
|
|
I would like to have a simple dialog so that user could change line style (color, thickness, and dashed/solid) of my object appearance. Is there any standard dialog available in MFC of doing this?
Beginner_1
|
|
|
|
|
The closest thing you get is the color dlg. For your application you'll need to create one.
|
|
|
|
|
I started off trying to use CSocket but then read that this doesnt call the callback functions OnAccept and OnConnect, because it simulates a blocking socket. So Instead I used CAsyncSocket which is a non blocking socket. My socket now connects (to a web server if this is relevant), but still my OnConnect function just doesnt get called. (i have overriden the virtual functions with a MessageBox - code below, would REALLY appreciate some help with this:
AfxSocketInit();
if( !m_Sock.Create() )
AfxMessageBox("Failed to create!");
else
{
if( !m_Sock.Connect( "www.loucoll.ac.uk", 80 ) )
{
itoa( m_Sock.GetLastError(), Buff, 10 );
AfxMessageBox( Buff );
}
}
and connection function:
void CConnectSocket::OnConnect(int nErrorCode)
{
AfxMessageBox("Connected!");
CSocket::OnConnect(nErrorCode);
}
thanks
|
|
|
|
|
I want to make a program that has an interface similar to Sub7 where you click a button and instead of opening a new dialog window, it changes the view inside that dialog....kinda like another dialog inside of the main dialog! Anyone understand my drift? Help would be appreciated!
Thanks
Ashman
|
|
|
|
|
Look at PropertySheet and PropertyPages?
|
|
|
|
|
I am currently having a problem with access to files on a dual processor machine that has a anti-virus scanner installed. The anti-virus scanner is Innoculate-IT from Computer Associates. CA advice is set the scanner to scan incoming only or add the file extension to the excluded list. Has anybody here had a similar problem and does anybody know of any other workarounds.
Thanks for any information you can provide.
Steve.
|
|
|
|
|
ok i have used the wizard to make an mfc windows explorer skeleton, but am lost as to where to put the tree forming code and document opening code, and saving code and other bits, please help cos i'm on work experience and thinking of finding bill gates ans custard pieing him - anything like an mfc source code for the windows explorer would be great -i've been hunting but no found any.
|
|
|
|
|
add a tool tip to a button?
pliz post some code...
thanks
|
|
|
|