|
Hello,
I'm developing a simple application to retrieve and display information from a user. There will be three full screen windows (only one open at a time). The screens will be dialog based (buttons, text boxes etc).
My question is this: Is it possible to create a MFC SDI and have single dialog child windows displayed one at a time, ie, I want a main frame (caption, toolbar etc) with a child dialog window, (maybe "child" is used in a wrong context here).
I'm a software engineering degree student and I have just started to use VC++.
Thanks in advance;)
|
|
|
|
|
|
A big thanks from Ireland
|
|
|
|
|
Hi there,
I have a dialog based application which uses a property sheet with several pages. I set the size for the Property sheet view when the pages are created to adjust the page size according to the display resolution.
However it is also necessary to change the page size when switching the windows system font size from small to large fonts.
But now my problem: How can I get the used system font size? (Small / Large)
Thank you for your help.
|
|
|
|
|
Heya,
This problem's been dogging me for a couple days already, so I'm asking you guys.
As you can see from the code below, I'm trying to implement a DirectDraw wrapper. One of my design goals is that the wrapper should automatically handle window size and resizing without relying on adding function calls and so on to track it in WinMain or in my WindProc.
I decided to solve this problem by simply comparing the client rect this frame to the client rect as it existed last frame. I even overloaded the != operator just so I could do it.
In theory, by simply calling GetClientScreenRect() I can get the screen coordinates of the client rect so that it can directly be used for blitting from a 'fake' DirectDraw backbuffer. Also, in theory, I could compare it to the client/screen rect from last frame to check to see if it's been resized. I could then set the window back to it's proper size using the SetWindowSize() function.
Each function appears to work fine independent of each other, but when I call SetWindowSize() before I call GetClientScreenRect(), ClientToScreen() returns some values that can only be described as "wonky".
In the example, below, I want 640x480 as the client area (m_iScreenX and Y). SetWindowSize() appears to work fine and the next time I call GetClientRect() in GetClientScreenRect(), it returns the values I'd expect (left and top == 0, right == 640, bottom == 480). But when I pass those coordinates in to ClientToScreen(), it returns the following rect: left == -32764, top == -32718, right == -32124, bottom == -32238. Even more curiously, if I subtract right - left and bottom - top, my requested client area pops out: 640x480.
Can anyone tell me why this is happening?
<br />
void CDirectDrawWrapper::SetWindowSize()<br />
{<br />
WINDOWINFO winfo;<br />
winfo.cbSize = sizeof(WINDOWINFO);<br />
if (GetWindowInfo(m_hWnd, &winfo))<br />
{<br />
RECT rectWindow;<br />
rectWindow.top = rectWindow.left = 0;<br />
rectWindow.right = m_iScreenX;<br />
rectWindow.bottom = m_iScreenY;<br />
<br />
AdjustWindowRectEx(&rectWindow, winfo.dwStyle, GetMenu(m_hWnd) != NULL,<br />
winfo.dwExStyle);<br />
<br />
MoveWindow(m_hWnd, CW_USEDEFAULT, CW_USEDEFAULT, <br />
rectWindow.right - rectWindow.left,<br />
rectWindow.bottom - rectWindow.top, FALSE);<br />
}<br />
}<br />
<br />
bool CDirectDrawWrapper::GetClientScreenRect(LPRECT pRect)<br />
{<br />
if (pRect)<br />
{<br />
GetClientRect(m_hWnd, pRect);<br />
<br />
if (ClientToScreen(m_hWnd, (POINT*)&pRect->left) && <br />
ClientToScreen(m_hWnd, (POINT*)&pRect->right))<br />
{<br />
return true;<br />
}<br />
}<br />
<br />
return false;<br />
}<br />
Thanks in advance,
DoomGaze
|
|
|
|
|
#pragma once
template<typename ty="">
class dzeta
{
Ty xval;
public:
dzeta(void);
virtual ~dzeta(void);
friend GetVal( const dzeta<ty>& );
friend GetVal2(const dzeta<ty>& DzA, const dzeta<ty>& DzB); //{return DzA.xval + DzB.xval;} /* works this way!! */
};
#include "StdAfx.h"
#include ".\dzeta.h"
template<typename ty="">
dzeta<ty>::dzeta(void)
{
}
template<typename ty="">
dzeta<ty>::~dzeta(void)
{
}
template<typename ty="">
GetVal( const dzeta<ty>& Dz)
{
return Dz.xval;
}
template<typename ty="">
GetVal2(const dzeta<ty>& DzA, const dzeta<ty>& DzB)
{
return DzA.xval + DzB.xval;
}
// USING THIS CLASS
dzeta<int> DzetaA, DzetaB;
int dzVals = GetVal2(DzetaA, DzetaB);
ERROR - LINKER - VC7.1 (Visual Studio 2003)
Compiling resources...
Linking...
GenPermut.obj : error LNK2019: unresolved external symbol "int __cdecl GetVal2(class dzeta<int> const &,class dzeta<int> const &)" (?GetVal2@@YAHABV?$dzeta@H@@0@Z) referenced in function _main
Debug/GenPermut.exe : fatal error LNK1120: 1 unresolved externals
It works ever using VC6 and VC 7.0 (Visual Studio 2002)
This message from LINKER is displayed in every case using template classes!
|
|
|
|
|
What are the return types of the friend functions?
Kuphryn
|
|
|
|
|
CLASS:
#pragma once
template<typename ty="">
class dzeta
{
Ty xval;
public:
dzeta(void);
virtual ~dzeta(void);
friend Ty GetVal( const dzeta<ty>& );
friend Ty GetVal2(const dzeta<ty>& DzA, const dzeta<ty>& DzB);
};
Operations:
#include "StdAfx.h"
#include ".\dzeta.h"
template<typename ty="">
dzeta<ty>::dzeta(void)
{
}
template<typename ty="">
dzeta<ty>::~dzeta(void)
{
}
template<typename ty="">
Ty GetVal( const dzeta<ty>& Dz)
{
return Dz.xval;
}
template<typename ty="">
Ty GetVal2(const dzeta<ty>& DzA, const dzeta<ty>& DzB)
{
return DzA.xval + DzB.xval;
Declarations:
dzeta<int> DzetaA, DzetaB;
int dzVals = GetVal2(DzetaA, DzetaB);
int dzVal1 = GetVal(DzetaB);
}
Compiling resources...
Linking...
GenPermut.obj : error LNK2019: unresolved external symbol "int __cdecl GetVal(class dzeta<int> const &)" (?GetVal@@YAHABV?$dzeta@H@@@Z) referenced in function _main
GenPermut.obj : error LNK2019: unresolved external symbol "int __cdecl GetVal2(class dzeta<int> const &,class dzeta<int> const &)" (?GetVal2@@YAHABV?$dzeta@H@@0@Z) referenced in function _main
Debug/GenPermut.exe : fatal error LNK1120: 2 unresolved externals
======
Default return was int and it works, but LINKAGE ERRORs disappear when:
#pragma once
template<typename ty="">
class dzeta
{
Ty xval;
public:
dzeta(void);
virtual ~dzeta(void);
friend Ty GetVal( const dzeta<ty>& Dz) {return Dz.xval;}
friend Ty GetVal2(const dzeta<ty>& DzA, const dzeta<ty>& DzB){return DzA.xval + DzB.xval;}
};
Generating Code...
Compiling resources...
Linking...
Build log was saved at "file://d:\VSProjects\v71\GenPermut\Debug\BuildLog.htm"
GenPermut - 0 error(s), 0 warning(s)
---------------------- Done ----------------------
Rebuild All: 1 succeeded, 0 failed, 0 skipped
|
|
|
|
|
hello,
i want to write a frontend for an audio encoder.
is there a way to start the encoder exe with the desired cmd line parameters and wait for its completion before starting the next encoding process?
thx!
|
|
|
|
|
Yes, but I can not remember the function name(s) right now. Since the question has been asked by other people in the past, I reccomend you check the FAQs and look for articles or totorials at codeproject. Also search MSDN library, that is where I found the information the one time I needed to do this.
INTP
|
|
|
|
|
:-DJust spoted this FAQ:
http://www.codeproject.com/system/newbiespawn.asp?target=FAQ
Enjoy!
INTP
|
|
|
|
|
thx man! i think my search methods suck...
|
|
|
|
|
Hi! I have a dialog with a Webbrowser activeX control. When I start a file download (Using save as in the context menu) the download dialog starts as expected. If I close my dialog however, the file download is also cancelled. Can someone explain why this is and how I should change my app to get the file dialog to stay alive after my app is closed.
Cheers
Dom
p.s. VC++ 6.0, Modal dialog.
|
|
|
|
|
Your app is the parent and when you close the parent all child processes and associated windows should also close. On solution may be to just hide (or minimize) the app when close is selected and let it wait until the download is complete or an error occurs, then finish closing the app.
INTP
|
|
|
|
|
I kind of thought that was going on. Any ideas how Internet Explorer does it?
Cheers
D
|
|
|
|
|
I do not know it you can shut down internet explorer with out canceling the download. The dialog that is showing the download progress is not a modal dialog and therefore you do not have to close it in order for you to do other tasks in your application. If you wanted to you could create a seperate app to do the download then launch it from your main app, that way it is just anouther program running in its' own thread.
I reccommend you look at the codeproject home page and look for aticles on dialogs under the "MFC controls" section.
INTP
|
|
|
|
|
Hi! I have a dialog in my application that has a beginners version with all the controls spaced out with text explaining what they do. I want the user to be able to check a box and get a different view of the same dialog with the same controls layed out more compactly. I can do this in a longwinded way by doing SetWindowPos() on all the controls, but I was wondering if there is a way to do this by designing the form in the form designer and changing which one is used at runtime.
Cheers
Dom
|
|
|
|
|
It sounds like you could just design 2 different dialogs containing the same controls with a different layout for both. You just needed to design your CDialog derived classes constructor to take an resource ID and maintian a variable some where that holds the curent ID to use.
There is the second option of placing the controls on top of each other and give them IDs like IDC_LISTBOX1, IDC_LISTBOX2. Then show controls with IDs ending with 1 when box is unchecked and show controls with IDs ending with 2 when box is checked. I see problems with this method: (1) you need to create 2 version of each command handler for each ID (1 & 2) [or manualy change the message map to direct commands to the same handle], (2) the more compact layout will probably require a dialog size change.
INTP
|
|
|
|
|
Thanks, I think option 1 sounds best. Any idea how the data would be shared between the controls on the different dialogs?
D
|
|
|
|
|
The same code would work for both dialogs the only difference between them is the dialog ID, every thing else remains the same.
Example:
1) Create dialog 1 and add all the controls you wish to appear on it.
2) Create dialog 2 select and copy all controls from dialog 1 and paste them to dialog 2, the rearange the controls as you see fit.
Now you have 2 dialogs containing controls with the exact same IDs.
When you create the dialog you would do some thing like this:
CMyDialog dlg(m_MyDlgID);
Since the only difference is the dialog ID and not the class used to create the dialog, the data source is the same for both dialogs.
INTP
|
|
|
|
|
Hi,
I have one namespace extension implemented, i want to access the addressbar of the explorer, how do i do that?
In the IShellBrowser interface there is a method GetControlWindow but this returns only toolbar,statusbar,tree and progress,
how do i get the handle to the addressbar.
Thanx regards,
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
it can count sin,cos....
thank you!!
|
|
|
|
|
*sigh*
did u all get visual studio for xmas or something?
try being a little more specific about what ur having trouble with and u might get some help
saying "i cant code" isnt going to cut it here im afraid
"there is no spoon" biz stuff about me
|
|
|
|
|
You need func of sin,cos...
so first
#include "math.h" to yr .cpp file than u direct getting the func abt what u need........
reply me +ve.....
|
|
|
|
|
l a u r e n wrote:
did u all get visual studio for xmas
Mean, but cute! And no, I've had it long enough for Microsoft to declare it obsolete - a couple of weeks, at least.;P
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|