|
We're lucky that
0XDEADBEEF != 0XBAADFOOD
This signature was proudly tested on animals.
|
|
|
|
|
|
Dear Mr enhzflep and Mr DavidCrow,
First of all, thank you so much about your clearly explanation.
I just still have a consideration, why the small expression (& 0xFFFF) has been still used in the expression ((l) >> 16) & 0xFFFF) here .
And this expression origins from window library, hix.
Why they still have used this expression if it was not necessary in here ?
Once again, thanks for your help, Mr enhzflep and Mr DavidCrow.
Best regards,
Duong Quoc Thang
|
|
|
|
|
Hi,
I'm trying to place a slider control (CSliderCtrl) on the status bar. The slider bar appears fine and I can move it around (either manually or by calling SetPos). However, I can't find where the WM_HSCROLL messages from the slider bar are sent to! I set the parent of the slider control to the status bar, but no WM_HSCROLL is sent to that window! Any ideas?
Here's what my code looks like. First off, I derived a class from CStatusBar to handle WM_HSCROLL:
class CMyStatusBar : public CStatusBar
{
public:
DECLARE_MESSAGE_MAP()
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
In my view class (e.g. CMySimpleProjctView) I added two members:
CSliderCtrl videoPosSlider;
CMyStatusBar statusBar;
and also a function called InitSliderBar() which is something like this:
void CMySimpleProjctView::InitSliderBar()
{
CMainFrame* frame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
statusBar = (CMyStatusBar*)(frame->GetStatusBar());
RECT rc;
statusBar->GetItemRect(0, &rc);
VERIFY (videoPosSlider.Create(WS_CHILD | WS_VISIBLE, rc, statusBar, 1));
videoPosSlider.SetRange(0, 50, 1);
videoPosSlider.SetPos(5);
}
When I run the program, the slider bar appears and I can move it around, but CMyStatusBar::OnHScroll() is not called when I move the slider. To test if everything else is fine, I changed the parent of the slider control to the view window in the code as
VERIFY (videoPosSlider.Create(WS_CHILD | WS_VISIBLE, rc, m_hWnd, 1));
and now CMySimpleProjctView::OnHScroll *is* called (but of course the slider bar appears at the wrong place, not on the status bar). I tried Spy++ to see where the WM_HSCROLL is sent to (when parent=status bar) but no WM_HSCROLL is sent at all! In fact no messages are passed when I move the slider around!!
Any ideas? thanks.
-Babak
(by the way, videoPosSlider.GetOwner() and videoPosSlider.GetParent() both return pointers that are identical to statusBar)
|
|
|
|
|
Hello,
I'm maintaining an MFC application that reads and writes from/to the registry. Previously, it used the HKEY_LOCAL_MACHINE key. However, this meant that Vista users needed full OS administrative privileges, (and perhaps non-admin XP users, but there aren't a whole lot of those around) which isn't desirable. So, I changed the key used to HKEY_CURRENT_USER. This just appears to not work at all on Vista as a regular user, though it does work elsewhere.
How can I store values in the registry without administrative privileges?
Regards,
Sternocera
|
|
|
|
|
Sternocera wrote: This just appears to not work at all on Vista as a regular user...
Do the registry functions fail?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).
I would recommend the manifest resource file with the security section since it allows you to use registry and file functions without getting false positives from virtualization. I use "AsInvoker" for user apps.
"Windows via C/C++, Fifth Edition" by Richter has some good information on dealing with Vista and using manifests correctly.
The Microsoft endorsed way of properly designing an application for UAC is to use a security manifest section in your manifest file/resource.
Windows Vista Application Development Requirements for User Account Control Compatibility[^]
Create and Embed an application manifest[^]
Certified for Logo Test Case[^]
|
|
|
|
|
Bob,
Thanks for that, but all I want to do is stored some key:value pair application settings! Surely there is a simpler way?
bob16972 wrote: You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).
Why? I thought that registry and file virtualisation where ways in which
Vista supported applications that used the registry.
Regards,
Sternocera
|
|
|
|
|
Just brushing up my C++ here, and a quick question.
I see people pass by reference using the following methods
&int x;
int & x;
int &x;
Difference? Which is better practice? When declaring a function definition and you want that function to accept a reference, how do you define that function heading?
double myFunction(&int);
?
or do you include the variable name?
double myFunction(int &x);
Sorry to make you go over the basics, my book isn't very clear...
|
|
|
|
|
AFAIK, this: &int x; isn't valid C++.
the other two are identical.
double myFunction(&int);
that's not legal, either.
i always include the variable name, since the header is the first place i look when looking for documentation.
|
|
|
|
|
Hey, thanks for the response.
So you include the variable name in the function definition? Seems like the smart thing to do I guess, I'll try to pick up on that habit.
Thanks for the reply. 5'ed.
|
|
|
|
|
EliottA wrote:
So you include the variable name in the function definition?
yeah. it's not strictly required, but it's really handy to people who want to use the function.
|
|
|
|
|
Chris Losinger wrote: but it's really handy to people who want to use the function.
especially when you have more than one parameter with the same type (as seen in our code)
void f(int, int, double, double, int, int& );
void f(int a, int b, double aa, double bb, int g, int& r){}
This signature was proudly tested on animals.
|
|
|
|
|
Hello,
EliottA wrote:
& int x;
int & x;
int &x;
The first one is plainly illegal.
The second and third have no difference between them. Ideally, I would prefer the third one to avoid any confusion while declaring multiple variables in the same statement. But while you are declaring such a reference variable, you *must* initialize it properly by specifying which variable is it referring to. Unless which, you won't get it to compile.
If a function takes a parameter in by reference (as opposed to 'by value'), any changes made to the variable passed in will reflect on the original variable passed while making the function call (similar to pointers, but the syntax is much cleaner).
This might help you:
void FuncRef(int &n)
{
n = 0;
}
void FuncNormal(int n)
{
n = 4;
}
void _tmain(int argc, _TCHAR* argv[])
{
int i = 10;
int &Ref = i;
cout<<Ref<<endl;
Ref = 2;
cout<<i<<endl;
FuncRef(i);
cout<<i<<endl;
FuncNormal(i);
cout<<i<<endl;
}
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I have two values say "rakesh,gender" parsed into a cstring object(say obj = "rakesh,gender") from a file..(say notepad)..
In my application, they have used Trimright() and Trimleft() functions for this obj;
I changed my notepad file as unicode (before it was ANSI) now..
After passing those two functions (trimright and trimleft), its showing the obj with one square box at the beginning..("(square box)rakesh,gender");
How to remove the square box??
Can anyone guide me how to solve this issue?
Thanks,
Rakesh
|
|
|
|
|
It seems you trimmed using ANSI functions over a UNICODE string or viceversa
If Trimleft and Trimright are from CString , verify your project has been compiled for UNICODE (see the project properties). Also, verify that no ANSI to UNICODE translations are attempred while reading the file by the fucntions.
To have a check, just do a per-step debug and look how the string is represented in meory just after the reading is finished, with a ASCII only text (saved as UNICODE).
It should be "xx 00 xx 00 xx 00 xx ..... " where xx a two hex digits.
If it is "00 xx 00 xx 00 xx" probably you saved also a BOM or you saved with the wrong endianess (it is an option of the format, during "Save As" - something like UTF-16LE or UTF-16BE: 80x86 use LE format).
If it is "xx xx xx xx xx" it has been read as ANSI.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi,
im drawing a char inside Crect variable...and if the Font size of the char is increased then how can i increase the rect size based on the change in Font size of char ...
|
|
|
|
|
kumar sanghvi wrote: ...how can i increase the rect size...
Have you looked at the CRect methods such as InflateRect() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You may use, for instance, GetTextExtentPoint32 [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ya..using GetTextExtentPoint32 ill get the width and height of the char..but how can i inflate the rect proportionally...may be should i inflate by the diff by which the char is changed...
Please correct me if im wrong..
|
|
|
|
|
When you know the geometric dimensions of your string then you may change the rectagle size accordingly (for instance, if your string has dimensions {w,h} then the rectangle maybe {w+b, h+b} where b is a fixed border, or, {w*(100+bp)/100, h*(100+bp)/100} where bp is a proportional border).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for ur reply...
but how can i get the fixed border "b" or proportional border "bp"....
|
|
|
|
|
Well, suppose the text width is 120 pixels and the height is 20 pixels, then, a rectangle with a fixed, 5 pixels, border would have width = 120 + 2*5 = 130 pixels and height 20+2*5 = 30 pixels.
If you prefer a proportional border, say 5% , you may set width = 120*(100+5*2)/100 = 132 pixels and height = 20*(100+5*2) = 22 pixels.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I am relatively new to working with Visual Studio/VC++. My requirement is to display an animation (AVI or AGIF) in a dialog control. This works fine. But what I also want is that when the dialog window screen is maximized, this animation (running in the dialog) should also resize/maximize accordingly. When the screen returns to normal position, the animation should also return to its normal size. Is is possible to do this? Right now, I'm only able to maximize the screen and not the animation (The animation is retaining its size). Please help!
|
|
|
|
|
You need to resize the control that play the animation manually; I assume when it resizes, it will resize the movie automagically.
This signature was proudly tested on animals.
|
|
|
|
|