|
Of course I can convert a hex number into decimal. You bit shift your total to the left 4 digits, then add the next number from your hex string! My biggest concern was that they specified not using scanf("%x") which I later looked up. You guys (and ladies) are all correct, they don't care that I use scanf, they just don't want me using %x because that will read a number already formatted in hexadecimal, which defeats the entire purpose of the program!
Thanks for the response though, I appreciate it!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
Does anybody know how to get the number and letters of local drives on a system?
|
|
|
|
|
|
I am new to designing my own OCX Controls and have managed to "hack" my way through and develop a workable control that seems to work. I was able to add in the Stock Properties OK and they too work. Somehow I managed to get Visual Studio (7.0) to add a COleControl wrapper class which is my interface to programatically change the stock properties. So far, so good.
I now wish to further add some variables that CxxxCtrl.cpp can access. It is at this point that I am throughly confused as to how to do this manually now that the control has been constructed.
A simple walk thru of "CWrapperClass::SetMyNewVariable(short NewVariable)" in the COleControl wrapper class and winding up in CxxxCtrl.h as "short m_MyNewVariable" in CxxxCtrl.h will do or even a reference to an article that will help me understand how to get from point A to point B.
This is strictly a run time function and does not to be persistantly stored or an ambient property.
Help, I'm running out of hair to pull out.
Thanks.
Barry
|
|
|
|
|
I want to be able to put in a line in the version info that specifies what the build is - e.g., Unicode Release, ASCII Debug, etc.
I tried to define a variable in the RC2 file (well, actually in an include file included from the RC2 file) that does this:
#ifdef _DEBUG
#ifdef UNICODE
#define VER_BUILDTYPE "Unicode Debug\0"
#else
#define VER_BUILDTYPE "ASCII/Multi-byte Debug\0"
#endif
#else
#ifdef UNICODE
#define VER_BUILDTYPE "Unicode\0"
#else
#define VER_BUILDTYPE "ASCII/Multi-byte\0"
#endif
#endif
PRoblem is, the define always says "ASCII/Multi-byte", as if UNICODE and _DEBUG aren't defined in resource files.
Is there any way to do what I'm attempting to do, short of going in the resource properies and manually defining symbols for all configurations?
Thanks.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Well, I found *one* way of doing what I want:
Simply define this string for all configurations in the "Resources" tab, "Defines" edit field:
VER_CFG=\"$(ConfigurationName)\0\"
And then reference VER_CFG wherever I need to in my RC files. This is less evil than having to put in the Debug and Unicode defines in the appropriate places, since at least one define can be used across all configurations here.
Still not sure why resources wouldn't automatically get the other project defines, though...
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
The defines are all passed in as command line arguments /Dxxxx=somevalue /Dxxxxx etc.
The resource compiler, MIDL compiler and C/C++ compiler all use individual settings. Defining _UNICODE isn't done for resource compilations or IDL compilations because it's a no-op. All resources are UNICODE for Win32 platforms.
In VC++6 you can go to 'Project/Settings' menu item, find your RC file and then see what additional defines you do/don't want for the various builds.
Steve S
|
|
|
|
|
I want to programmatically turn off the video signal so my display will power down into standby. I'd like to selectively turn off each video signal on a dual-channel VGA.
I did this years ago by tweaking a VGA register under DOS. Now I'm looking for a Windows API to do it.
Any suggestions? Examples?
Alternatively, I've heard there's a VESA standard to send device control info via the VGA port?
TIA
|
|
|
|
|
I have an application written in VC++6 that has been working great for some time, but I recently added a menu bar item with two submenu selections to respective message handlers.
It works well on my machine and any others in my group that have VC++ installed, but doesn't show any response, error or change if these new sub-menu items are selected on any other machine.
Our plant just changed over to XP at the same time, (so the water is now muddy!) but we can't find any hard correlation except that the custom menu selections (previously added in other versions) that used to work with the old workstations under Win98 are now giving a message
"Attempted an unsupported operation!"
Does anyone have any suggestions?
I will add some prompts to see if I even get into the message handler, but I don't think that it does!
David Leikis
ATK Thiokol Propulsion
Laboratory Automation
|
|
|
|
|
You may be using a library that is installed when you install VC++. Try compiling your project with a statically linked library instead for shared DLL.
|
|
|
|
|
Hi,
I would like to be able to resize the MDI before start up,
I mean, i want to make it really small,
How can I resize it in my code?
Ehsan Behboudi
|
|
|
|
|
The simplest solution I can think of:
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.y = my.y;
cs.x = my.x;
cs.cx = my.cx;
cx.cy = my.cy;
if( !CNewMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
INTP
|
|
|
|
|
Hi,
I have a MFC "multi-document" application where I draw a cube.
I want to be able to roate the cube by clicking on a button ...
+----------------------------------------------------------+
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|:+---------------------------------------------+:::::::::
|:|ooooooooooooooooooooooooooooooooooooooooooooo|:::::::::
|:|ooooooooooooooooooooooooooooooooooooooooooooo|:::::::::
|:|ooooooooo+==============+oooooooooooooooooooo|:::::::::
|:|ooooooooo|\oooooooooooooo\ooooooooooooooooooo|:::::::::
|:|ooooooooo|o\oooooooooooooo\oooooooooooooooooo|:::::::::
|:|ooooooooo|oo\oooooooooooooo\ooooooooooooooooo|:::::::::
|:|ooooooooo|ooo\oooooooooooooo\oooooooooooooooo|:::::::::
|:|ooooooooo|oooo+==============+ooooooooooooooo|:::::::::
|:|oooooooooo\ooo|oooooooooooooo|ooooooooooooooo|:::::::::
|:|ooooooooooo\oo|oooooooooooooo|ooooooooooooooo|:::::::::
|:|oooooooooooo\o|oooooooooooooo|ooooooooooooooo|:::::::::
|:|ooooooooooooo\|oooooooooooooo|ooooooooooooooo|:::::::::
|:|oooooooooooooo+==============|ooooooooooooooo|:::::::::
|:|ooooooooooooooooooooooooooooooooooooooooooooo|:::::::::
|:|_____________________________________________||::::::::
|:|______________<PUSH2ROTATE>__________________||::::::::
|:|_____________________________________________||::::::::
|:+---------------------------------------------+:::::::::
Sorry for the ugly graphic above but I don't know enough about MFC (What things are called) to describe this in any other way. Please help
|
|
|
|
|
There are several solutions. One solution is a splitter window. One side is the control. The other side is the view.
Kuphryn
|
|
|
|
|
That will work. How do I go about making a splitter window?
|
|
|
|
|
There are a couple relatively easy ways, in addition to the splitter idea the other guy suggested.
1. Create a control dynamically. Have an object of, say, CButton, in your header file, and then in the view class initialization, create the button with the desired attributes. For instance:
// in header file
protected:
CButton myButton;
// in initialization function
myButton.Create(blah);
Look in MSDN for the parameters to Create, you will have size, position, caption, etc. One important one is the control ID. You can use that control ID in your message map so you can define a handler that controls what happens when the button is clicked.
2. Handle mouse clicks (e.g., OnMouseUp). Check if the mouse position is within a certain area, and then do whatever you feel like doing.
#1 is probably cleaner, since you get an actual button, but 2 is probably a little easier.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Hi,
I have posted this question before and got an answer, but for some reasons it doesn't seem to work, or I have the code at the wrong place.
I copy pasted the code in my InitInstance()
so now it looks like the following:
BOOL CMotionControllerApp::InitInstance()
{
// CG: The following block was added by the Splash Screen component.
\
{
\
CCommandLineInfo cmdInfo;
\
ParseCommandLine(cmdInfo);
\
\
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
\
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMotionControllerDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMotionControllerView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
/////////////////////////////////////////////////////
//This is the code, it is at the correct spot?
/////////////////////////////////////////////////////
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
//////////////////////////////////////////////////////
// The one and only window has been initialized, so show and update
// m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
// m_pMainWnd->UpdateWindow();
return TRUE;
Ehsan Behboudi
|
|
|
|
|
Post the code that hides the window. One solution is SW_HIDE.
Kuphryn
|
|
|
|
|
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
or
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
CChildFrame *childFrame=(CChildFrame *)pMainFrame->GetActiveFrame();
childFrame->PostMessage(SW_HIDE);
|
|
|
|
|
I posted a much longer question about this on the COM forum but got no responses so I'll try to phrase this shorter and hope for luck here.
I have a dialog based MFC application that contains a class that supports automation. The problem is that the server exits when I close the dialog even though I have clients (.vbs scripts) accessing the automation class. Anyone know how this should be changed so that closing the dialog for the application doesn't kill the server unless the reference count is zero? I don't understand why this isn't the default behaviour.
Gil Jones
|
|
|
|
|
You might want to invest into: AfxOleApp(); / AfxOleUnlockApp();
|
|
|
|
|
The automation class already contains those calls as inserted by the ClassWizard.
Just try this and you should see the problem:
1) Create a new single dialog MFC application called TestServer.
2) Change TestServer.cpp to look like the following:
COleTemplateServer::RegisterAll();
if (RunEmbedded() || RunAutomated())
{
return TRUE;
}
else
{
COleObjectFactory::UpdateRegistryAll();
}
3) Add a class called Interface1 derived from CCmdTarget that is creatable by type id TestServer.Interface1.
4) Add a get property to Interface1 called StepSize and have it's implementation return 5.0.
5) Create a file called test.vbs which contains the following:
Dim x
set x = CreateObject("TestServer.Interface1")
WScript.Echo x.StepSize
WScript.Echo x.StepSize
6) Execute the application which will bring up the dialog.
7) Then double-click the test.vbs file to execute it.
8) Before you close the windows script host messagebox that returned "5", hit the "OK" button on the dialog which will close it.
9) Then hit "OK" on the windows script host messagebox.
10) You will see the error message that the remote server machine does not exist. So I want to know how to change this so that closing the dialog doesn't kill the server.
Gil
|
|
|
|
|
Gil,
If it's DialogApp you must have CDlgAutoProxy derived class which is your OutProc Proxy.
In constructor of the proxy you must have this line or similar:
m_pDialog->m_pAutoProxy = this;
Now put the following code in destructor of CDlgAutoProxy:
if(m_pDialog)<br />
m_pDialog->m_pAutoProxy = NULL;
Now overload OnClose message handler of your dialog and put the following code in there:
if(!m_pAutoProxy)<br />
CDialog::OnClose();
You are basically ignoring Close when Proxy exist.
Hope, this works.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Ah...now I see why it's not working for me...the CDlgAutoProxy code is never running. I have an application called MicroTouch and I added an interface called Focuser. If I create an object of "MicroTouch.Application", then the proxy code executes, but when I create my "MicroTouch.Focuser" object, the proxy code never runs. So it looks like I need to replicate some of the proxy code into my Focuser class such as the following:
ASSERT (AfxGetApp()->m_pMainWnd != NULL);
ASSERT_VALID (AfxGetApp()->m_pMainWnd);
ASSERT_KINDOF(CRCMicroTouchDlg, AfxGetApp()->m_pMainWnd);
m_pDialog = (CRCMicroTouchDlg*) AfxGetApp()->m_pMainWnd;
m_pDialog->m_pAutoProxy = this;
The other thing that makes this more difficult to fix it that I'm not using the main dialog but instead I'm using a property sheet for the main GUI interface. I think I'll need to override OnQueryCancel() in every property page to catch all the places where the application can exit.
Gil Jones
|
|
|
|
|
Thanks for your help! You comments led me in the right direction and I got my test project working and now I just need to do the same thing in my real project. The only difference is that my real project is using a property sheet for the main dialog so I hope that doesn't cause too much trouble.
One thing I found is that I had to remove the "return TRUE" from the "if (RunEmbedded()...." part of the if because the proxy code fails if there is no dialog active. I had to instead just HIDE the dialog.
The final solution still seems a little crude to me. I had to change the dialog class so that it tracked how many automation connections were active from my Focuser interface class and the Focuser class destructor had to call the dialog's OnClose method which I have issuing a PostQuitMessage() if the number of connections is zero. I'm sure I probably have a race condition now.
Gil
|
|
|
|