|
Hi,
I just need to need how to play a midi instrument sound... Please, not how to playback midi-files - just how to play different notes!!!
I have currently got a working program using only MFC that reads the midi-in, but I might switch to directX if that is easier to implement...
(I am trying to write a program that reads tones from midi-in, and then plays three notes tango-style based on the note hit on the midi-keyboard...)
Thanks alot,
|
|
|
|
|
Is there a sure fire way of predicting a dialog's rectangle without creating it?
Happy programming!!
|
|
|
|
|
I've not done this, but it appears you can find this information out by loading the dialog resource into memory without actually creating the dialog. Look up the functions FindResource , LoadResource , and LockResource for how to load the dialog resource into memory. Look up function CreateDialogIndirect and structure DLGTEMPLATE for information on what the memory looks like.
Software Zen: delete this;
|
|
|
|
|
I'm having difficulty with implementing a custom MFC control on an eVC Pocket PC dialog-type application. I create a custom control derived from CStatic following the methods of the CDoubleListPicker custom control example I found on this site, and when I run the program I can see the caption fine, but not the sub-controls that are created in my custon control.
Just to check on this problem, I took the CDoubleListPicker application and ported it to eVC, basically taking out things that aren't supported by the eVC environment, like the about box and resizing of the dialog. When I run this program, I have the same problem that none of the internal controls of CDoubleListPicker appear. I really made an effort to only take out the code that the compiler gave errors on, so I don't think I took out anything critical.
I will admit that I am only running this on the emulator, as my new device has not arrived yet, but I wanted to get a head start on programming...
Here's the class that I created, as well as what I think are the most critical functions.... Note that in the app I added a CStatic object to the dialog using the graphical dialog editor, and associated this control with the variable m_FileChooser of type CFileChooser (the custom control class).
Any help would be appreciated.
class CFileChooser : public CStatic
{
public:
CFileChooser();
public:
#define ID_BASE_ID ((UINT)-1)
enum {
ID_DIR_DROP_BOX = (ID_BASE_ID - 1),
ID_FILE_LIST_BOX = (ID_BASE_ID - 2),
};
public:
public:
virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
protected:
virtual void PreSubclassWindow();
public:
virtual ~CFileChooser();
protected:
void DoSizing();
int CreateChildControls();
CComboBox m_dirDropBox;
CListBox m_fileListBox;
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnEnable(BOOL bEnable);
DECLARE_MESSAGE_MAP()
};
int CFileChooser::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
if (!CreateChildControls())
return -1;
return 0;
}
void CFileChooser::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
SetWindowText(_T("FileChooser"));
ModifyStyleEx(WS_EX_STATICEDGE, 0);
CreateChildControls();
DoSizing();
}
int CFileChooser::CreateChildControls()
{
if (m_dirDropBox.GetSafeHwnd() != NULL)
return TRUE;
CWnd* pParent = GetParent();
if (pParent == NULL)
return FALSE;
CRect rc(0, 0, 0, 0);
if (!m_dirDropBox.Create(DW_DROP_STYLE, rc, pParent, ID_DIR_DROP_BOX))
return FALSE;
if (!m_fileListBox.Create(LBS_MULTIPLESEL|DW_LIST_STYLE, rc, pParent, ID_FILE_LIST_BOX))
return FALSE;
BOOL bEnable = IsWindowEnabled();
BOOL bShow = (GetStyle() & WS_VISIBLE);
m_dirDropBox.EnableWindow(bEnable);
m_dirDropBox.ShowWindow(bShow ? SW_SHOW : SW_HIDE);
m_fileListBox.EnableWindow(bEnable);
m_fileListBox.ShowWindow(bShow ? SW_SHOW : SW_HIDE);
return TRUE;
}
void CFileChooser::DoSizing()
{
if (m_dirDropBox.GetSafeHwnd() == NULL)
return;
if (GetParent() == NULL)
return;
CRect rc;
GetWindowRect(&rc);
GetParent()->ScreenToClient(&rc);
m_dirDropBox.ShowWindow(GetStyle() & WS_VISIBLE ? SW_SHOW : SW_HIDE);
m_dirDropBox.MoveWindow(rc.left, rc.top, rc.Width(), DROP_BOX_SIZE);
rc.top += BOX_CTRL_GAP + DROP_BOX_SIZE;
m_fileListBox.MoveWindow(rc.left, rc.top, rc.Width(), rc.Height());
RedrawWindow();
m_dirDropBox.RedrawWindow();
m_fileListBox.RedrawWindow();
}
- Kati
|
|
|
|
|
In order to do this so my edit control can be resized everytime the text changes I assume I have to use SendMessage(hwndEditCtrl, EM_SETMARGINS, EC_USEFONTINFO, NULL); I have yet to accomplish this task...Can anyone give some advice as to how to approach this problem?
|
|
|
|
|
You can size the edit control with MoveWindow or SetWindowPos.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
Hi!
I have modified the sample application from MSDN lib and having a trouble: Custom Control with interfaces
CEdit
A
|
|
CParsedEdit
A
|
|
CParsedEditExport (for custom controls)
Now I change design pattern: extract interface from implementation, and enable RTTI in compiler option, theoretically:
CEdit IEdit(abstract as interface)
A A
| /
| /
CParsedEdit
A
|
|
CParsedEditExport (for custom controls)
Here is the code:
interface:
class IEdit {
public:
virtual void setText(TCHAR* text)=0;
virtual int getText(TCHAR* text, int count)=0;
};
class CParsedEdit : public IEdit, public CEdit {
public:
virtual void setText(TCHAR* text) { SetWindowText(text); }
virtual int getText(TCHAR* text, int count) { return GetWindowText(text, count); }
protected:
....
};
user:
class CWclsEditDlg : public CDialog {
public:
IEdit* Edit1()
{ return dynamic_cast<IEdit*>(GetDlgItem(IDC_EDIT1)); }
IEdit* Edit2()
{ return dynamic_cast<IEdit*>(GetDlgItem(IDC_EDIT2)); }
IEdit* Edit3()
{ return dynamic_cast<IEdit*>(GetDlgItem(IDC_EDIT3)); }
IEdit* Edit4()
{ return dynamic_cast<IEdit*>(GetDlgItem(IDC_EDIT4)); }
....
};
Does anyone know how to solve this?
Thanks.
Sovann.
Why waste time learning while ignorence is instantaneous ? [Hobbes]
|
|
|
|
|
Sadly, dynamic_cast (and it's MFC cousin) won't work on CWnd::GetDlgItem() since it actually returns a CWnd (which is very likely to be a temporary object). Hence the dyanmic cast will fail.
The best way would actually be to subclass your edit controls using DDX_Control()...that way you can manipulate them directly without using GetDlgItem().
Anna
"Be yourself - not what others think you should be" - Marcia Graesch
|
|
|
|
|
I'm trying to access a parallel port in my project...
I've got a DLL that should solve my troubles, but the problem is: How do I use a DLL in Visual C++?
|
|
|
|
|
There are mainly two options you have:
1. If you have the dll, a .h file describing the functions available in the dll and a .lib file you should be able to #include the .h file and add the lib file to your linker settings. Then you can call the functions in the dll just like any other function.
2. If you however have only got the dll itself and know the layout of the functions then you would have to use ::LoadLibrary / ::GetProcAddress to load the address of the function you want to call at runtime. Assuming the function you want to use takes two parameters; one integer and one LPCTSTR; and returns BOOL then you could use a code similar to this:
<br />
typedef BOOL ( CALLBACK* MyExportedFunction )( int, LPCTSTR );<br />
<br />
HINSTANCE hInst = ::LoadLibrary( _T( "theDLLIWantToUse.dll" ) );<br />
<br />
if ( hInst != NULL )<br />
{<br />
MyExportedFunction myFunc = (MyExportedFunction) GetProcAddress( (HMODULE)hInst, _T("TheFunctionIWantToCall") );<br />
if ( myFunc != NULL )<br />
{<br />
BOOL bRetVal = myFunc( 7, _T("This is a string parameter") );<br />
}<br />
::FreeLibrary( (HMODULE)hInst );<br />
}<br />
<br />
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi.
I added a simple CListCtrl box with a List style to a dialog box. However, I cannot insert more than one item. Another possible problem is that Windows is not drawing the other items. Nonetheless, only one item shows up. Here is an example what how I inserted items.
-----
OnInitDialog(...)
{
LVITEM Item;
Item.mask = LVIF_TEXT;
Item.state = LVIS_SELECTED;
Item.stateMask = LVIS_SELECTED;
Item.cchTextMax = 0;
Item.iImage = 0;
Item.lParam = 0;
Item.iSubItem = 0;
Item.pszText = TEXT("November");
// I would like to insert ten items in the list box.
for (unsigned i = 0; i < 10; ++i)
theListBox.InsertItem(&Item);
-----
After the insertion above, only one line of "Novermber" will show up in the CListCtrl box.
I have worked with CListCtrl boxes using Report Style. I have not had this problem. I would like to know why does it ignore all new items except the first line?
Thanks,
Kuphryn
|
|
|
|
|
Okay - I'll be the first to admit I don't know what I'm doing. But it looks like you're trying to insert the same item (ie, same memory address pointing to the item) multiple times.
I would try creating a second LVITEM called Item2, insert that, and see if you get multiple values in the CListCtrl. In the .InsertItem() function it may actually check and see if an item is already there, and if so, don't add it again.
- Kati
|
|
|
|
|
From MSDN
iItem
Zero-based index of the item to which this structure refers.
so... change your code to:
for (unsigned int i = 0; i < 10; ++i)
{
Item.iImage = i;
theListBox.InsertItem(&Item);
}
This sets the index of the item to something other than 0.
That's why I ramble so much. If you're short and quotable, there's a much greater danger of ending up in a sig.
[Christopher Duncan on how to prevent yourself from ending up in a sig]
|
|
|
|
|
Okay. Thanks everyone.
I decided to go back to the same solution I have been using on othe projects: Report style. It works perfect.
Kuphryn
|
|
|
|
|
You should fill in the item index.
Item.iItem=i;
|
|
|
|
|
Hello!
To detected LButton hold (for many minutes if you want) when mouse is moving we write:
void XXX::OnMouseMove(UINT flags, CPoint p)
{
if ( flags & MK_LBUTTON ) {
....
}
}
How can I detect LButton hold ( for many minutes ) when mouse is not moving ?
Thanks,
Sovann.
Why waste time learning while ignorence is instantaneous ? [Hobbes]
|
|
|
|
|
WM_LBUTTONDOWN and WM_LBUTTONUP.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You could also try ::GetAsyncKeyState( VK_LBUTTON );
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
VC++ 6
For a custom control, I have to show / hide the focus rect in SetFocus / KillFocus, and in accordance to the "Windows painting rules" (i.e. message handlers invalidate regions, and all drawing is done in WM_PAINT) I've come up with the following solution:
a) WM_SET/KILLFOCUS creates a region that is just the focus rectangle, and invalidates it
b) WM_PAINT draws the focus rect(if necessary), then stops anything else when the remaining area is not part of the update region
Now, this sounds like a little bit of overkill here. any GDI gurus coming up with something better?
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
It may be simpler to set some member variable "bFocusChanged" inside the WM_SET/KILL FOCUS messages, then do an Invalidate on the control. In the WM_PAINT handler, check if the flag is set, and if so, only redraw the focus state. After this, set the bFocusChanged to FALSE. I'm not sure if this is the best way, but it will be less expensive than region testing.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I thought of that too - but this would drop any other invalidates that are either pending, or happen between the message handler and the actual WM_PAINT.
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
This is overkill. Just draw the control and paint a focus rect afterwards if the control has the focus. For Set/Kill focus, invalidate the whole control (without forcing a background redraw).
|
|
|
|
|
I am writing my own shell. Where can I get info on how to create taskbar and systray and make them work ?
I am seaching for information fro two months!
Help!
|
|
|
|
|
The taskbar is an example of an "App Bar". Take a look at SHAppBarMessage in the MSDN. It provides all you need to create your own.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|