|
I've been two days at this problem and can't figure it out - I'd really appreciate your advice and time to help me
The problem is this:
My application draws a road and shows vehicles moving on it. When scrolled right and I zoom in, the scrollbars move to the left, back towards the origin. Conversly, when I zoom out they scroll to the right. As you can see from the code below I have tried adjusting for the viewport origin, but still no luck.
Some more information:
My logical coords have their origin at the start and centre of the road. I therefore set my viewport origin at (left border, Rect.Height()/2). To scale I use a scale factor times my draw area. I am not using CZoomView[^] because I need the above special considerations.
Here is the code I have:
void CTrafficView::OnPrepareDC(CDC *pDC, CPrintInfo *pInfo)
{
CScrollView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(m_DrawArea);
int xExtent = m_Scale * m_DrawArea.cx;
int yExtent = m_Scale * m_DrawArea.cy;
pDC->SetViewportExt(xExtent, yExtent);
GetClientRect(&m_ClientRect);
CPoint viewOrg;
viewOrg.y = m_ClientRect.Height()/2;
viewOrg.x = m_Border_Lhs*m_Scale;
viewOrg -= GetDeviceScrollPosition();
pDC->SetViewportOrg(viewOrg);
}
void CTrafficView::ResetScrollBars()
{
CClientDC aDC(this);
OnPrepareDC(&aDC);
CSize temp = m_DrawArea;
aDC.LPtoDP(&temp);
SetScrollSizes(MM_TEXT, temp);
}
void CTrafficView::OnToolsZoomin()
{
CPoint pt;
GetClientRect(&m_ClientRect);
pt.x = (m_ClientRect.Width() / 2);
pt.y = (m_ClientRect.Height() / 2);
CClientDC aDC(this);
OnPrepareDC(&aDC);
CPoint vp = aDC.GetViewportOrg();
pt = pt - vp;
CScrollView::ScrollToPosition(pt);
m_Scale += 0.2;
ResetScrollBars();
Invalidate();
}
Thanks so much for any help you can give - I have to present my program at a meeting with the client tomorrow
modified on Thursday, August 7, 2008 7:26 AM
|
|
|
|
|
i have a main dialog with some controls,
i also have a second dialog(modeless) and i want to make it into child.
when selected style "popup" in the child dlg properties
the "child" dlg acts normal, but its not what i want, because i only want the child dlg to appear inside the main dlg, not anywhere else on the screen.
opening the child dlg, when selected style "child" in the dlg properties,
the main dlg gets painted onto the child dlg making it a transparent mess.
how can i get the "child" dlg to be painted correctly?
this is the code that opens the modeless "child" dlg:
void CMyApp::OpenChDlg()
{
CChildDlg *dlg;
dlg = new CChildDlg;
dlg->Create(IDD_CHILDDLG);
dlg->ShowWindow(true);
}
thx
|
|
|
|
|
To be a child, doesn't the child need a parent?
What about passing a valid parent to Create()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanx,
but how do i find the name of the parent?
ive tried some of my class names and so on..
i tried to find it in CWnd *pParent and the main dlg class, but i cant get a hold of it,
..errors..
even tried this:
made a global var at the start of maindlg:
CWnd* pParentWnd = CWnd::GetActiveWindow();
stored in pParentWnd
CChildDlg *dlg;
dlg = new CChildDlg;
dlg->Create(IDD_CHILDDLG, pParentWnd);
dlg->ShowWindow(true);
// works fine until move the mouse, then messed up and its overpainted by the maindlg..
theres something im missing..
thx
modified on Wednesday, August 6, 2008 4:22 PM
|
|
|
|
|
You're the one that creates all the windows. You should be able
to get a CWnd * somewhere. I'm not sure what the problem is here.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i have some updateData(),updatewindow(), and a "SetWindowPos(&wndTopMost,NULL,NULL,NULL,NULL,SWP_NOMOVE|SWP_NOSIZE);" funcs in the maindlg, maybe thats why the childdlg get overpainted? but i dont have it enabled on mousemove func.. strange.
|
|
|
|
|
rolfhorror wrote: ...i only want the child dlg to appear inside the main dlg, not anywhere else on the screen.
Something like this?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All,
We are trying to internationalize our software. To do this, we created resource bundles for various languages. However, after doing this we realized that all the .rc files needs to be updated when a new dialog is added to the project. To over come this problem, we moved all the strings to a header file and used to #defined in the .rc files. Now, we had to only update the header files for each of these languages and add the new dialog only in one .rc. The same rc file was linked all the resource bundle projects. Example as shown below.
As created by the resource editor:
IDD_DIALOG1 DIALOGEX 0, 0, 186, 90
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Test Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Sample text",IDC_STATIC,25,21,39,8
END
After replacing all the strings with constants:
ResourceBundle_en-US.h:
#define TEST_DIALOG “Test Dialog”
#define OK “OK”
#define CANCEL “Cancle”
#define SAMPLE_TEXT “Sample Text”
IDD_DIALOG1 DIALOGEX 0, 0, 186, 90
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION TEST_DIALOG
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON OK,IDOK,129,7,50,14
PUSHBUTTON CANCEL,IDCANCEL,129,24,50,14
LTEXT SAMPLE_TEXT,IDC_STATIC,25,21,39,8
END
The above code just works fine when you compile and run. The problem is when you try to add new dialogs or other resources from the resource editor. The resource editor replaces all the #defines with the actual strings and creates a new resource.h file. Is it possible to instruct resource editor not to replace the #define with the actual strings? or are there any other way to accomplish the same result -- Have a header file to specify all the strings used in the project and not in a resource file or define resources like dialog only once? We are currently using Visual Studio 2005.
Thanks,
Anand
|
|
|
|
|
Since dialog box sizes may change with each language and to simplify the life of your translators, it is best to create a resource file for each language.
In one small project, every set of resources had a base ID that was linked to a language. Internally, a resource was then requested based on an ID + the base language ID. I've had other projects where we simply had two builds and others where the language specific resources were in their own DLLs--this last one is probably the most common approach.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'm using the below code to enumerate the available pixel formats. For each pixel format, I'm checking the flags to see if this format provides HW accelerated rendering. I'm getting "NONE" for half the formats and "GENERIC" for the other half. I don't get "ACCELERATED" for any of them. I've tried this on multiple machines which have hardware that I would expect to provide HW accelerated OpenGL rendering.
PIXELFORMATDESCRIPTOR pfd;
int maxpf = DescribePixelFormat(hDC,0,0,NULL);
for (int i = 1; i <= maxpf; i++)
{
if (DescribePixelFormat(hDC,i,sizeof(PIXELFORMATDESCRIPTOR),&pfd) == 0)
continue;
if ((pfd.dwFlags & PFD_SUPPORT_OPENGL) == 0)
continue;
if ((pfd.dwFlags & PFD_GENERIC_ACCELERATED) != 0)
{
TRACE1("%d: ACCELERATED\n", i);
}
else if ((pfd.dwFlags & PFD_GENERIC_FORMAT) != 0)
{
TRACE1("%d: GENERIC\n", i);
}
else
{
TRACE1("%d: NONE\n", i);
}
}
So my question is what is the correct way to determine which pixel formats support HW accelerated rendering? Are the flags in the pixel format even the right place to look?
One site I found which discusses this is below:
here
Seems pretty vague though unfortunately.
modified on Wednesday, August 6, 2008 9:53 AM
|
|
|
|
|
Hi,
I am getting the following error message when I login as a standard user and invoke my applicatin from SUA and close it.Can anyone help me resolving this errors.
Detailed information
Privs: Called GetTokenInformation, requesting 'TokenOwner'
Stack Trace
vfluapriv2!NS_LuaPriv::FudgeGetTokenInfo+3f
vfluapriv2!NS_LuaPriv::VfHookGetTokenInformation+6a
mscorwks!GetMetaDataInternalInterfaceFromPublic+1b11a
mscorwks!GetMetaDataInternalInterfaceFromPublic+bb96
mscorwks!GetMetaDataInternalInterfaceFromPublic+1bbcb
mscorwks!GetMetaDataInternalInterfaceFromPublic+1bb4c
mscorwks!GetMetaDataInternalInterfaceFromPublic+1b52b
mscorwks!GetMetaDataInternalInterfaceFromPublic+1b849
mscorwks!GetMetaDataInternalInterfaceFromPublic+b5c3
mscorwks!GetMetaDataInternalInterfaceFromPublic+b31b
mscorwks!GetMetaDataInternalInterfaceFromPublic+b2ba
mscorwks!CoInitializeEE+56
mscorwks!GetAddrOfContractShutoffFlag+c0
mscorwks!GetAddrOfContractShutoffFlag+a7f
Thanks,
Venkat
|
|
|
|
|
Can you > and < to find the greater of two floating point (float) numbers in C?
Or do I have to do something else like write a function?
|
|
|
|
|
johnny alpaca wrote: Can you > and < to find the greater of two floating point (float) numbers in C?
what ? what is the verb in your sentence ?
if you're asking "can I compare two floats using < and > operators", the short answer is : yes. the long one would say to be careful when comparing floats/doubles because of decimal precision...
but that makes a question come to mind : why didn't you just test it ?
|
|
|
|
|
verb "use"
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i don't see it then
|
|
|
|
|
Sorry for the bad english.
Thanks I thought so. It worked on my PC but just wanted to confirm that it could be done without any problems just like integers.
Also what about testing equality of two floating point numbers ?
They could be tested for almost equality as I understand it
|
|
|
|
|
You can get into trouble checking the equality of floating point numbers.
As a decimal example, if you did an operation such as adding 1 + 1.
x = 1.0 + 1.0;
the internal respresentation might end up being
x = 1.999999999999999999999999999999999
instead of 2.0000000000000000000000000000
if you then checked if (x == 2.0) that would be false instead of true.
|
|
|
|
|
johnny alpaca wrote: They could be tested for almost equality as I understand it
Yes, you are right; floating points are not well represented in binary forms, so that a value like 1.4 can be stored as 1.39999999 or 1.400000001 ( for example)
so if yo need to compare floating point numbers, you have to check them against a pre-defined precision; they are identical "up to" a certain precision
for example:
double x;
double y;
double epsilon = 0.00001;
bool bEqual = fabs( x - y ) < epsilon;
this is a good read : http://docs.sun.com/source/806-3568/ncg_goldberg.html[^]
|
|
|
|
|
johnny alpaca wrote: They could be tested for almost equality as I understand it
Yes, with the difference being epsilon.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
I want to make enteries in add remove program through coding...
how can i do this??
|
|
|
|
|
hey you asking from the base .......if we do means ...what abt your knowledge ...???
ok any ill give some tips
give AddString() function for add button
and take the index value,and then give deletestring() button for remove button...
i think this tips may be help for u ...
|
|
|
|
|
WTF are you talking about ?
the OP is asking how he can add an entry in the "Add / Remove Programs" Section of Windows.
how can AddString() and DeleteString() help him in this regard ?
moreover, your english is quite hard to read. please avoid SMS-typing.
|
|
|
|
|
You would need to create a key in the registry under HKEY_CLASSES_ROOT\Installer\Products
with ProductName and value (that you want to appear in the add/remove program)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
sorry guys its for my mistakes..
|
|
|
|
|
I am working on a DLL which hosts various dialogs and property sheets which is being developed in Visual Studio 2003. I would like to have Windows XP styled controls but not having much luck so far.
I have tried using #define ISOLATION_AWARE_ENABLED 1 along with embedding a manifest and calling InitCommonControls(); in the constructor for the item but at best it does nothing, at worst it crashes. I have been searching for a way to do this and tried various tools which embed the manifest but they do not seem to have an effect. I have seen articles which suggest setting the manifest in the linker options but I cannot see the option so I believe this must be a 2005+ option.
Is there a way to do this or is it just not possible in 2003 projects?
|
|
|
|
|