|
RegCreateKeyEx opens key if it exists and creates it if it doesn't exist - exectly what you need in such situation.
In any case program should check return code and handle errors. For example, if you run program in Guest account, RegCreateKeyEx may fail.
|
|
|
|
|
I have a CformView containg a list ctrl and other application also is the same.Files are displayed with icons in list ctrls ,i need to drag and drop from one list ctrl to another and vice versa.Plz help me as the deadline for the project is abt to be finished.
|
|
|
|
|
i have an edit control on dialog box and i am not using MFC, i want to validate that only numbers should be entered in the field. what is the possible way out. help me out PLZ
|
|
|
|
|
You're better off doing it yourself anyhow. Handle WM_KEYDOWN in the edit control, and then you can do your own validation. You can set the number style, or if you need negative numbers or decimals, you can deal with that in the same message.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
Handle WM_KEYDOWN in the edit control
Actually, I think he would be better off handling the EN_UPDATE notification, that way he can properly validate any text that is pasted into the edit control.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
In the resource editor with the dialog box displayed, right click the edit control, select properties, select the styles tab, then check the Number checkbox. This will allow only the digits 0-9.
|
|
|
|
|
i need to change programatically the tile of the dialog box. Is there anybody having idea which api to use
|
|
|
|
|
SetWindowText
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hello,
I have a program that makes images smaller before sending. I do not modify the original image so I make a resized copy into a temporary folder. Then I use
MAPISendMail(NULL, NULL, &mapiMsg, (FLAGS)(MAPI_LOGON_UI | MAPI_DIALOG), 0) to start the email client software. If users use outlook then the function doesn't return until the mail got send out or it closed. However, if users use such as netscape mail or hotmail as default email program then the function return right after it started. The problem is that I delete those temprary files right after MAPISendMail return. If I do not delete them right away, when should I delete them? There's no way for me to know when those file don't need anymore.
Any solutions?
Thanks,
Hiusing
|
|
|
|
|
|
Nishant S wrote:
MoveFileEx(filename,NULL,MOVEFILE_DELAY_UNTIL_REBOOT)
This will mark the file for deletion, next time the computer starts
Cool!!! Learn something new every day
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
I created a little app where you throw a ball and it bounces. You can see the app here:
http://thresholdx.com/misc/Ball.exe
To throw the ball, hold the left mouse button, gain some speed and release. I bet you know what I mean . Oh and if it jumps wildly when you run it, just restart the app, it is some silly bug I will get to later.
I have two problems with it.
1) When the speed of the ball is high its motion stops to be smooth and you can basically see him jumping and moving The reason is that to make the illusion of speed I move the ball more and more pixels at a animation-timer-tick.
One solution I thought of is to make the number of pixels the ball moves always 1 but instead change the animation timer frequency. The bigger is the frequency the faster will the ball move.
Problem is that the regular Win32 timer is too slow for such task and can't move the ball quickly enough. I read the article on CodeProject and figured I should use the multimedia timer.
What do you think? Am I on the right path here?
2) The ball flickers.. It is not very visiable but it happens and that means I am doing something wrong.
Here's my code to draw the ball (and delete the previous one):
void CBall::Draw(int X, int Y)
{
// Deletes the previous ball draw
BitBlt(m_DialogBox.Dc(), m_X, m_Y, m_Size, m_Size, m_Background, 0, 0, SRCCOPY);
// Copies the current background
BitBlt(m_Background, 0, 0, m_Size, m_Size, m_DialogBox.Dc(), X, Y, SRCCOPY);
// Draws the ball
Ellipse(m_DialogBox.Dc(), X, Y, X+m_Size, Y+m_Size);
m_X = X; m_Y = Y;
}
Is there some general problem with my way (probably is)?
Thank you.
P.S How do I activate some [b], [code] etc?? Couldn't find anything it and the post looks ugly =(.
Vitaly Belman
|
|
|
|
|
You probably want to draw in WM_ERASEBKGRND, but if you want speed, you'll need instead to use DirectX.
To post code, use <pre> tags.
this is my code
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
The WM_ERASEBKGND works too.. It improved the flickering a bit.
However, didn't make them go completly. Also, it wouldn't be a good idea if I wanted to have a background.
What do they use in real 2d games that it moves so nicely? I mean.. Obviously whatevern you can do with DirectX is achievable with regular Win32 functions.
Vitaly Belman
|
|
|
|
|
Vitaly Belman wrote:
What do they use in real 2d games that it moves so nicely?
DirectX
Vitaly Belman wrote:
mean.. Obviously whatevern you can do with DirectX is achievable with regular Win32 functions.
Obviously not, or why would DX exist at all ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
That's WM_ERASEBKGND, Christian. That'll cover up the problem with the remnants of windows on the ball.
A simple app like yours doesn't need something fancy like DirectX. Keep working at it.
Peter O.
|
|
|
|
|
Peter Occil wrote:
That's WM_ERASEBKGND, Christian.
*blush*
Peter Occil wrote:
A simple app like yours doesn't need something fancy like DirectX. Keep working at it.
It depends on what sort of speed he wants and what his hardware is. It *probably* does not need DirectX, but that is the way to get maximum speed, nonetheless.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hello,
I have a list view, and at run time I want to know if the horizontal scroll bar is visible. I would also like to get the height of the horizontal scrollbar.
Thanks
|
|
|
|
|
Hello,
I have a list view, and at run time I want to know if the horizontal scroll bar is visible.
This is not so easy. Try this function.
BOOL IsScrollBarVisible(HWND hwnd, UINT fnBar){
SCROLLINFO si;
if(fnBar==SB_CTL)
return IsWindowVisible(hwnd);
si.cbSize=sizeof(SCROLLINFO);
si.fMask=SIF_PAGE|SIF_RANGE;
GetScrollInfo(hwnd,fnBar,&si);
if(si.nMin==si.nMax)
return FALSE;
if(si.nMin>si.nMax)
return FALSE;
if(si.nPage>=(si.nMax-si.nMin))
return FALSE;
return TRUE;
}
Call IsScrollBarVisible(hwndListView,SB_HORZ) to check if the horizontal scrollbar is visible. Written only a few minutes ago, untested, so beware.
I would also like to get the height of the horizontal scrollbar.
This, by comparison, is easy. Simply call
GetSystemMetrics(SM_CYHSCROLL) .
Peter O.
|
|
|
|
|
|
Ok, I used to have a problem where I would get an error where my compiler wouldn't recognize the ifstream in my function declarations, but then it just went away. Then just recently it came back plus it wouldn't recognize a pointer to a class I made in any function declarations. So I commented out the declarations that had an ifstream variable or a variable from my class and built my program. I got 31 errors, simply uncommented the declarations, and all was well Whats going on?
-Raffi
|
|
|
|
|
Sounds to me like the sort of problem that is fixed by a rebuild all. By changing the affected files, you forced a build on them. When that sort of error happens to me, the first thing I do is clean/rebuild all, then spend the build time thinking about what else it might be.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Thanks, I'll try that next time.
-Raffi
|
|
|
|
|
I'm a beginner programmer with no formal training so forgive me for asking such a basic question.
I'm having trouble passing information between dialogs. For instance, if I pop up a dialog and have an edit box that accepts a piece of data, when the edit box closes i'd like to get that piece of data to the main dialog.
My testbed for figuring out how to do this has been a simple MFC dialog app with an about box. I have added an edit box to the about dialog, and when I click 'ok' i'd like the main dialog to be able to access that variable.
I can easily solve the problem with a global variable but from what little studying i've done I know that it's "bad programming" and sloppy. I don't want to kick off my programming education with bad techniques so can someone explain the proper way to do this? An explanation in terms of working with the about box scenario described above would be most helpful.
Thank you.
|
|
|
|
|
Otyug wrote:
so forgive me for asking such a basic question.
Remember, the person who answers probably asked it once as well
I'm glad you've researched enough to understand that globals are a bad idea. If you're creating a modal dialog, the answer is a variable in your dialog class. The edit box is a window and therefore gone when the dialog closes, but if you store the contents of the edit box into a string, that will be accessible after it closes. So if you define a string called m_sEdit in the dialog, and set it to equal GetWindowText on the edit box in OnOK, then
CMyDlg dlg;
if (IDOK == dlg.DoModal())
{
AfxMessageBox(dlg.m_sEdit;
}
Strictly speaking, the variable should be private and a get method exposed, but in a case like this I think that is redundant. You can't set it to anything meaningful either before or after the modal loop in any case.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|