|
Hello,
I am new to MFC and the device context stuff. I have read some sample codes and write a simple program. It has a dialog with a button and a groupbox. When the button is pressed, an image is drawn to the groupbox by retrieving its hDC. This works fine but I don't know how to keep the image visible after refresh. How to handle this (like AutoRedraw in VB?) in VC?
As a related question, I have tried to modified the program so that the dialog is a pop up window rather than the main window. I want to display the image as soon as the dialog is visible. I have tried to put the drawing code in OnInitDialog() and DoModal(), but got no luck. I guess it is the same refresh problem as above, but I am not sure. Will this problem be solved when the above refresh problem is solved? Or I need some more special handling?
Thanks in advance.
|
|
|
|
|
Try to use Invalidate(TRUE) in the OnInitDialog()
|
|
|
|
|
I have a large project which contains some number of VC exe and Dll projects. Threre are number of versions of this project. However, currently I don't manage Version resource and each project contains default FILEVERSION and ProductVersion 1, 0, 0, 1, empty CompanyName etc. Anybody have idea how can I manage version information (except of opening each project and setting these values manually)?
Thank you.
|
|
|
|
|
I want to create one Class : have 2 button (starttime and stoptime) and 2 statictext (display start time and stop time)
when I click to starttime button it get current time and display to statictext and stoptime button too.
please help me, how to write it or send me your source. Thanks
|
|
|
|
|
Hi !!
Does anyone know how I can avoid the login window with Windows2000 ? I would like to automatically log into a specific user account without having to enter the password each time I boot win2000.
Thanks for your help !
Jérôme
|
|
|
|
|
TweakUI[^] has an option for this (along with many other handy options)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Have you looked at Q97597 ?
|
|
|
|
|
Open the Users control panel, it's the very first option there (uncheck "users must enter a password")
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi,
my application plays a WAV file to sign some action. The file is 12KB and plays ca. 1 second sound. I'd like to include more sounds and reduce the size of the executable. For example for graphics I switched over to compressed TGA files and drastically (!) reduced file size.
Question: Can I shrink the size of my WAVs? Perhaps WAV format do provide various (compressed) formats; and which tool should I use?
For playing the sound I use this code snippet (IDR_WAVE_PING is my file linked to the resource):
PlaySound(MAKEINTRESOURCE(IDR_WAVE_PING),AfxGetInstanceHandle(), SND_ASYNC + SND_RESOURCE + SND_NODEFAULT);
Thanks for feedback!
PS: I don't use MP3 or OGG yet, because I don't want to ship 3rd party DLLs with my exe. I'd like to have a "stand-alone" executable (at the moment). If there are any alternatives I should have a look at, please tell me.
|
|
|
|
|
The code to play a single mp3 is here on CP, in a skinnable app example.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Including MP3 support in software pretty much requires using either Windows Media Player or paying royalties.
The way that is fairly easy (and cheap) is to simply use Windows Media Player:
1. Run Visual C++ 6 and open your project
2. Select "Project" > "Add to Project" > "Components and Controls" .. then from the "Component and Controls Gallery" dialog select "Registered ActiveX Controls" then "Windows MediaPlayer", then click "Insert".
3. Then in your program:
CMediaPlayer2 wmp;
wmp.Create( ... );
wmp.Open( FILENAME );
wmp.Play();
-OR-
Add the control to a dialog and map it to a variable and do something like:
m_wmp.Open( FILENAME );
m_wmp.Play();
Viola... instant support for MP3, WMA, and all the other Windows Media Player (WMP) formats... WMP has a big fat runtime at Microsoft that you can redistribute for free for systems that don't have it.
If you want something else such as everything in one EXE then you essentially have to pay royalties. For example, this company makes (what I assume) is a fairly nice royalty-based SDK:
http://www.xaudio.com -- they offer both static and dynamic link libraries
Regards, Larry Antram
Stardust Software
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
-- Albert Einstein
|
|
|
|
|
Larry Antram wrote:
Including MP3 support in software pretty much requires using either Windows Media Player or paying royalties.
What? Nonsense!
There are a number of free (as in GPL) MP3 players out there.
If one really cares about freedom (of patents and that crap) one should go for Ogg Vorbis (www.xiph.org). It's tried-and-proven by f.ex. the game Serious Sam, not to mention all the media players that also supports it. Well, not Microsoft of course, but that's to expect: It's free, therefore it must be communism, anti-american, cancer and the plague. All-in-one solution to both keep your money and piss MS off. It can't get much better!
|
|
|
|
|
What I said is not nonsense. MPEG Layer-3 algorithms are patented -- and as such -- a license and royalty payments are required to use them in software.
See: http://www.mp3licensing.com/help/developer.html
Regards, Larry Antram
Stardust Software
"Why are we here? What is the purpose of life? A lot of people say it's meaningless. Nonsense. There's no use having a cosmos, no use having a universe, if you don't have an audience. The universe, needing an audience, created us. We are the meaning of life."
-- Ray Bradbury [Interview, April 18, 2002]
|
|
|
|
|
Mike Nordell wrote:
There are a number of free (as in GPL) MP3 players out there.
GPL is not possible in (my) commercial software, since I'm not allowed to provide the source (which GPL asks for). Also I would prefer OGG over MP3, no patent payment required.
|
|
|
|
|
So, why don't you use OGG then? There's no DLL involved (unless, of course, you opt to actually compile it to a DLL).
|
|
|
|
|
Christian
which app did you mean?
|
|
|
|
|
The skinnable application sample, which is also an mp3 player. Search for mpeg instead of mp3, the mp3 matches are useless, they just use DirectPlay.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I can't imagine TGA offering that much of a benefit. I would think PNG or JPG would be better -- which one depends upon the image type. (See "CxImage" elsewhere on this site).
WAV files can contain audio data in ANY format (even MPEG Layer-3). The thing is, however, no matter what the format is, the system of an end-user must have the appropriate codec installed to play it back. That's the problem.
Being that you are concerned about 3rd party files you are basically stuck with whatever codecs Windows ships with, by default. I have not done exhaustive research, but I assume that would mean PCM is about as good as that is going to get. And those files are big and fat.
If Ogg Vorbis (the MP3 clone) is truely royalty-free and offers a Win32 static-link library (I don't know as I haven't looked) then I would consider using it if size matters.
Regards, Larry Antram
Stardust Software
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
-- Albert Einstein
|
|
|
|
|
Larry Antram wrote:
If Ogg Vorbis (the MP3 clone) is truely royalty-free and offers a Win32 static-link library (I don't know as I haven't looked) then I would consider using it if size matters.
I'll have a look on OGG again. thx for all tips!
|
|
|
|
|
I'm a beginner and my question might seem a little bit stupid.
What I'm basically trying to do is: I open a MFC Dialog. I place WebBrowser2 control, 2 button controls and an edit control (this is a sort of webbrowser) and I open another dialog (in the function OnInitDialog, that is generated by VS). I want to use the second modeless dialog as a floating toolbar (like in photoshop) for the other browser buttons (back, forward, refresh) but I cannot pass the events to the first dialog (clicking of a button). How can I do that? Are there any working (and simple enough - I mean clear) examples? I couldn't find any on my own.
What is the best way in C++ to access some object member function from another object, where the first object is created as a variable in a third object (just like the MFC dialogs above - to make it clear). In the case above I cannot use global pointers because I get linker errors).
Best regards,
H
|
|
|
|
|
Say your main dialog is called CMainDlg. Put a CMainDlg * into your modeless dialog and use it to call methods in the main dialog when button are pushed in the floater.
You may get a cross dependancy thing happening, you beat that by putting class CMainDlg(); into the top of the modeless dialogs header, and include the real file in the cpp.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I have a column of CEdit controls to get values for up to 10 fields. For each control, I'd like to do some processing on EN_CHANGE, such as storing the value to an array.
Rather than add one distinct handler function for each instance of ON_EN_CHANGE in the message map, I'd like to be able to pass the index of the control as a parameter to a common handler.
i.e., rather than:
ON_EN_CHANGE(IDC_VALUE1, OnChangeValue1)
ON_EN_CHANGE(IDC_VALUE2, OnChangeValue2)
...
I'd prefer something like:
ON_EN_CHANGE(IDC_VALUE1, OnChangeValue(1))
ON_EN_CHANGE(IDC_VALUE2, OnChangeValue(2))
...
The compiler spits out errors if I try variations of this. Is there a way to do something to this effect?
Thanks for any help.
|
|
|
|
|
You could override PreTranslateMessage() to intercept the processing of the change message for a range of control IDs:
For example:
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
// EN_CHANGE is in the high word of wparam
if ( WM_COMMAND == pMsg->message && EN_CHANGE == pMsg->wParam >> 16 )
{
// the control id is in the low word of wparam
UINT nID = pMsg->wParam & 0xFFFF;
if ( nID >= IDC_VALUE1 && nID <= IDC_VALUE10 )
{
OnChangeValue( nID - IDC_VALUE1 + 1 );
return TRUE;
}
}
return CDialog::PreTranslateMessage( pMsg );
}
Dave
|
|
|
|
|
|
Thank to all! ON_CONTROL_RANGE is exactly what I was looking for.
Dave's PreTranslateMessage method worked for me too, but this looks cleaner for a simple job.
|
|
|
|