|
How do you set the master volume for sound devices? There appears to be no simple way to do this; Every time I try to find something, I end up being bogged 10 miles deep in random WINMM functions that, in my opinion, should've been depreciated about 3 versions ago. Mind you, I don't want to control the WAVE volume, I want the "What you Hear" volume, or in other words, what is set when you left-click the Sound tray icon.
|
|
|
|
|
You're gonna want to use the mixerSetControlDetails() function. See if MSDN article Q178456 helps. It's in VB, but easily translated.
|
|
|
|
|
Hi, guys:
How to convert a non-mfc multithreading vc++6.0 win32sdk program to a mfc one ?
Any suggestion/advice is much appreciated.
TIA
|
|
|
|
|
WHy would you want to do that ? Code in win32 is better than MFC IMHO.
Hari Krishnan
|
|
|
|
|
I have to convert my program to an ocx.
And I've got that it's very difficult to implement it from a win32 one.
Somebody told me it's a little easier to do that from a mfc one.
Am I right or wrong ?
Any advice ?
|
|
|
|
|
If it's a standalone windows program like SDI/MDI/or Dialog: solution maybe very easy:
Just create standard MFC COleControl application:
1. Overload OnCreateWindow -- add to it creation of your main Win32 SDI/MDI/Dialog frame or window; immediately after that call SetParent on it so your Control Window will becomw parent of it -- also you may need to change style of your Win32 window to WS_CHILD -- remeber m_hWnd32 handler to your SDI/MDI/Dialog frame here in one of member variables;
2. Overload OnSize of your COleControl and resize your m_hWnd32 here to occupy all available space of COleControl;
3. Remove message pump from the original code of your application -- you are running on message pump of container now;
4. Add PreTranslateMessage to you COleControl and perform appropriate calls to your win32 app returning true/false if appropriate...
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Thanks for your kind and clear direction.
But my program is not a simple SDI/MDI/Dialog one, instead, something more complex.
Does your solution fit this ?
Thank you very much !
|
|
|
|
|
No...;P
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
What a pity!
Are there any other ways in which I can finish my task ?
Thanks a lot for your help anyway!
|
|
|
|
|
Instead of using MFC, why not consider ATL. Yes, writing a control is not necessarily easy, but instead of bloating your control by using MFC, ATL will take much of the pain away...
Steve S
[This signature space available for rent]
|
|
|
|
|
convert my program to a MFC one then convert the MFC one to an ocx. He also told me the first step need only minor change on source and the latter is also not very difficult.
Time is so limited though I'm not familiar with VC++...
Can you give me some further help?
Thank you very much !
|
|
|
|
|
Hi,
I'm about to spontaneously combust if I can't manage to set the color of one single little button in a dialog. It seems that with OnCtlColor() I can set the color of EVERYTHING EXCEPT my button's foreground. Please help me before I blow!
I know I am missing something probably very simple. Do I need to use OnDrawItem()?
Thank you for any suggestions. I am relatively new (1 year) to MFC so be kind and if possible detailed in your suggestions. Thank you so much.
Here's one of several bits of code I have tried :-
//CBrush is set within OnInitDialog()
m_brush.CreateSolidBrush(RGB(0,0,255)); // Blue brush
....
HBRUSH CTry_button_colorsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//this works ok - my editbox ends up a nice blue color
if (nCtlColor == CTLCOLOR_EDIT || nCtlColor == CTLCOLOR_MSGBOX )
{
pDC->SelectObject(m_brush);
hbr = this->m_brush;
}
//THIS DOES NOT WORK
if (nCtlColor == CTLCOLOR_BTN)
{
hbr = this->m_brush;
pDC->SetBkColor(RGB(0,0,255));
}
//THIS DOESN'T WORK EITHER
if( pWnd->GetDlgCtrlID() == IDC_MYBUTTON)
{
pDC->SetBkColor(RGB(0,0,255));
pDC->SelectStockObject(WHITE_BRUSH);
}
return hbr;
}
Michael
|
|
|
|
|
You can't change the button colour using OnCtlColor() . You'll have to create an owner-draw button to do this.
michael thomas wrote:
I'm about to spontaneously combust
Don't spend too much time in the sun then...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
If you want to change the color of a dialog button, you have to use owner-draw button. (you can use bitmap buttons) Changing the color through OnCtlColor() will not work for buttons. The following Knowledge Base articles may be of help to you:
ID: Q32685 TITLE: Using the WM_CTLCOLOR Message
ID: Q64328 SAMPLE: Owner-Draw: 3-D Push Button Made from Bitmaps with Text
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Thanks for the help.
Michael
|
|
|
|
|
I have 2 tables in mydatabase "Account" and "Employee"
I want to edit my record but there is a Error messagebox always show
-----------------------------
"Recordset is read-only"
-----------------------------
How can I fix it?
thanks
<br />
<br />
<br />
<br />
IMPLEMENT_DYNAMIC(CAccountSet, CRecordset)<br />
CAccountSet::CAccountSet(CDatabase* pdb)<br />
: CRecordset(pdb)<br />
{<br />
m_ID = _T("");<br />
m_Pass = _T("");<br />
m_Employee_ID = _T("");<br />
m_Permission = 0;<br />
m_nFields = 4;<br />
m_nDefaultType = dynaset;
}<br />
<br />
CString CAccountSet::GetDefaultConnect()<br />
{<br />
return _T("ODBC;DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:\\MyDB.mdb");<br />
}<br />
<br />
CString CAccountSet::GetDefaultSQL()<br />
{<br />
return _T([Account],[Employee]);<br />
}<br />
<br />
void CAccountSet::DoFieldExchange(CFieldExchange* pFX)<br />
{<br />
pFX->SetFieldType(CFieldExchange::outputColumn);<br />
RFX_Text(pFX, _T("[ID]"), m_ID);<br />
RFX_Text(pFX, _T("[Pass]"), m_Pass); <br />
RFX_Long(pFX, _T("[Permission]"), m_Permission); <br />
RFX_Text(pFX, _T("[Employee_ID]"), m_Employee_ID);<br />
}<br />
<br />
<br />
class CChangePassword : public CDialog<br />
{<br />
public:<br />
CChangePassword(CWnd* pParent = NULL);
<br />
CAccountSet m_Set;<br />
.....<br />
}<br />
<br />
<br />
<br />
<br />
void CChangePassword::OnOK() <br />
{<br />
.......<br />
m_Set.m_strFilter = "Account.ID = Employee.Employee_ID";<br />
m_Set.Open(CRecordset::dynaset,<br />
_T( "SELECT ALL Account.ID,Account.Pass,Employee.Permission FROM Account INNER JOIN Employee ON Account.ID=Employee.Empoyee_ID" ),<br />
CRecordset::executeDirect);<br />
<br />
<br />
m_Set.Edit();<br />
m_Set.m_Pass = strNewPass; <br />
<br />
m_Set.Update( ); <br />
m_Set.Requery ();<br />
m_Set.Close();<br />
.....<br />
}
|
|
|
|
|
Hello,
I have a CDialogBar with many run-time-generated progress bar windows on it. I would like to handle the event when the user clicks on one of these progress bars but after trying many message map entries, I cannot seem to find the right way to funnel these messages to any function of mine.
I've tried to simply intercept the ON_WM_LBUTTONDOWN message, but it is only called if the user clicks in the dialog bar EXCEPT for in my progress bar windows.
I can intercept the event in the progress bar class, but I want to handle it in the parent (CDialogBar) class---is there any way to funnel it back to the parent class?
Any ideas/help?
thanks!
JennyP
|
|
|
|
|
If all else fails, intercept it in the progress bar class, and use GetParent()->SendMessage(WM_LBUTTONDOWN, ...) .
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
when I use the writestring(); function it works everything but i get one compiler error cannot convert parameter 1 from 'class CTime' to 'const char *' HELP!
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
Hello,
CTime has many member functions---one is called ".format()" and returns a CString, and I'm sure this CString can easily be converted to a char * type (perhaps by a CString function or a (char *) cast).
cheers,
JennyP
|
|
|
|
|
There are several ways of doing this...
CTime time = CTime::GetCurrentTime();<br />
CStdioFile file;<br />
file.WriteString(time.Format("The time is %x\n"));
or
CString str;<br />
str.Format("The time is %s\n", time.Format("%x"));<br />
file.WriteString(str);
etc...
|
|
|
|
|
Hi,
I'm trying to use a spin control so that when it changes a number in its buddy window, other items in the dialog box are changed (ie. some options are greyed out depending on the value). I am *not* using MFC, just the straight Window API.
Unfortunately, I can't get it to work properly. I read on MSDN that you should use NM_RELEASEDCAPTURE with WM_NOTIFY, and that NM_RELEASEDCAPTURE uses a NMHDR structure - unfortunately, I'm a novice, and this means nothing to me - and all searches for information on NM_RELEASEDCAPTURE elsewhere have turned up blank.
Could somebody please show me a small piece of sample code, showing how to use NM_RElEASEDCAPTURE with WM_NOTIFY?
I tried doing it without NM_RELEASEDCAPTURE like this:
case WM_NOTIFY:
switch(wParam)
{
case IDC_SPIN1:
EnableWindow(ADlgItem,o);
break;
}
break;
This just about worked, but only very, very strangely... If someone could show me the right way to do this I would be really grateful.
Many thanks,
KB
|
|
|
|
|
I had the same need, in a palette editing dialog I wrote. Here are some relevant code snippets:
ON_NOTIFY(UDN_DELTAPOS, IDC_SPINRED, OnDeltaposSpinRed)
...
void CPaletteEdit::OnDeltaposSpinRed(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
*pResult = 0;
int nNewPos = pNMUpDown->iPos + pNMUpDown->iDelta;
if (nNewPos < 0)
{
nNewPos = 0;
*pResult = 1;
}
if (nNewPos > 255)
{
nNewPos = 255;
*pResult = 1;
}
COLORREF cRef = m_rgbMain;
cRef = RGB (nNewPos, GetGValue (cRef), GetBValue (cRef));
m_rgbMain = (cRef);
m_rgbBaby [m_nCurrentColour] = cRef;
m_pPaletteSettings->rgbPalette [m_nCurrentColour] = cRef;
PaletteRefresh ();
}
As this is cut and pasted from my app, the last bit is app specific. m_rgbMain is a colour display
static control that has operator= overloaded.
I hope this helps,
Iain.
|
|
|
|
|
Hi, thanks for your help, I really appreciate it. I think I forgot to mention that I'm a relative novice, and as I'm just using the straight SDK with no MFC, I'm having problems converting your code for use with WM_NOTIFY. Do I create a function similar to your OnDeltaPosSpinRed() function and then somehow call it from WM_NOTIFY?
Sorry if this is a very basic question.
Many thanks,
KB
|
|
|
|