|
| Notices |
Welcome to the DriverHeaven.net forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
 |
Aug 28, 2005, 06:24 PM
|
#1
|
|
DriverHeaven Addict
Join Date: Dec 2002
Posts: 259
|
I need a 'Text Edit' control.
I need to use an editable (not static) text control in a plugin. My idea is to use a CEdit control, but I think I don't have enough C++ skills to do that. I have searched the web, but all the examples I have seen uses the Visual Studio dialog creator, and what I need is to create the control 'manually'. Well, I can create it, but nothing more. I think that I need a message-handler member function...., but wich?
P.D.:The plugin I am making is a compressor (the name is 'e-Compressor'), a simple version of Dynamics Processor, that uses less resources (58 vs 92 intructions and 40 vs 54 registers), but with a new option to choose between Peak detector or RMS detector (Dynamics Processor uses a Peak detector).
I'm thinking too in a Lite version, with less quality, but only with 25 instructions and 25 registers.
Here you have an image: Capture
|
|
|
Aug 28, 2005, 07:07 PM
|
#2
|
|
DriverHeaven Lover
Join Date: Sep 2003
Location: Romania
Posts: 123
|
yes, Cedit is the way, check mixy sourcecode, it is on my website in my signature, but as i know it cannot be saved with presets.
nice vus in your plugin btw 
|
|
|
Aug 28, 2005, 09:20 PM
|
#3
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
CEdit is not difficult to use. If your want some help, just let us know which CEdit function you would like to use. There are examples in some of the plugins (like townkats) that might help, depending on what you want to do.
Basically you need to add:
"DECLARE_MESSAGE_MAP()" to the pluginDlg class, and the handler for the function that you want to use. Look up "Edit Control Handlers" in MSDN, and you will see that they all take the basic form of "afx_msg void memberFxn( );" where memberFxn( ) is the name that you want to give for the function. i.e. if you wanted to handle the ON_EN_UPDATE message from CEdit, you would add something like the following to you pluginDlg class:
Code:
//-------------------------------------
afx_msg void on_edit1_update();
DECLARE_MESSAGE_MAP()
//-------------------------------------
(the afx_msg part is optional, and the on_edit1_update can be what ever you want to use for the name of the function).
Then in your plugin.cpp, add the message map stuff and the implementation of your handler. Again Look up "Edit Control Handlers" in MSDN, and you will see that the message map entries generally take the form of "MESSAGE( <ctrl_id>, <memberFxn> )
ie. using ON_EN_UPDATE again would be as follows
Code:
//-------------------------------------
BEGIN_MESSAGE_MAP(iYourPluginDlg, CKXPluginGUI)
ON_EN_UPDATE(EditCtrlID, on_edit1_update)
// add message map handlers for any MFC controls here
END_MESSAGE_MAP()
void iYourPluginDlg::on_edit1_update()
{
// do something
}
//-------------------------------------
That is pretty much all there is to it (other than creating the control, which you said you know how to do). You can also use ON_CONTROL_RANGE if you want to map a group of controls to the same handler. (you would just need to make sure that the ctrl_id's for all the control's that you want to group together are contigious). If you look at the code that the MFC dialog editor and class wizard adds for you, you will see that it is very much the same (except that it also adds DDX stuff).
Last edited by Russ; Aug 28, 2005 at 11:11 PM.
Reason: typo
|
|
|
Aug 28, 2005, 11:32 PM
|
#4
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
BTW: I should probably also mention that the above message map entry is the equivalent to the following (which you are more likely to see in other kX plugins):
Code:
//-------------------------------------
BEGIN_MESSAGE_MAP(iYourPluginDlg, CKXPluginGUI)
ON_CONTROL(EN_UPDATE, EditCtrlID, on_edit1_update)
// add message map handlers for any MFC controls here
END_MESSAGE_MAP()
//-------------------------------------
|
|
|
Aug 29, 2005, 07:45 AM
|
#5
|
|
DriverHeaven Addict
Join Date: Dec 2002
Posts: 259
|
Yes, that is what I need, and it works. Thanks.
Just one more question: How can I make the control to lose the focus when I'n editing the text and press enter?
|
|
|
Aug 29, 2005, 02:45 PM
|
#6
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
That is a little trickier in kX. Normally when you press enter in a CEdit, it causes the default button to be pressed. kX Dialog's do not seem to have any default buttons (i.e. pressing enter in kDialog does nothing.) There are a few options but it is tricky to explain, and some of them are hacks. I am not completly sure what would be the best way to do this with kX.
|
|
|
Aug 29, 2005, 06:07 PM
|
#7
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
Here is one method. It is kind of a hack but it should work.
Create MyEdit.h and MyEdit.cpp containing the following:
MyEdit.h
Code:
#if !defined(AFX_MYEDIT_H__B6056503_CAF0_4FDA_A8C7_D8EE8448D0A2__INCLUDED_)
#define AFX_MYEDIT_H__B6056503_CAF0_4FDA_A8C7_D8EE8448D0A2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyEdit.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyEdit window
class CMyEdit : public CEdit
{
public:
CMyEdit();
virtual ~CMyEdit();
protected:
//{{AFX_MSG(CMyEdit)
afx_msg UINT OnGetDlgCode();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYEDIT_H__B6056503_CAF0_4FDA_A8C7_D8EE8448D0A2__INCLUDED_)
MyEdit.cpp
Code:
#include "stdafx.h"
#include "MyEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyEdit
CMyEdit::CMyEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_GETDLGCODE()
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlers
UINT CMyEdit::OnGetDlgCode()
{
return CEdit::OnGetDlgCode() | DLGC_WANTALLKEYS;
}
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == 13)
GetParent()->SetFocus();
else
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Then add an include for MyEdit.h to yourPlugin.h,and replace your CEdit's with CMyEdit.
|
|
|
Aug 30, 2005, 07:41 AM
|
#8
|
|
DriverHeaven Addict
Join Date: Dec 2002
Posts: 259
|
Okey, I'll try it. Thanks a lot.
Here you have the final look: Capture.
Only a few details in GUI, and the plugin should be terminated. 
|
|
|
Aug 30, 2005, 03:30 PM
|
#9
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
It looks good eyagos, and I like the idea a having a low resource alternative to the Dynamics Processor.
|
|
|
Aug 31, 2005, 11:35 AM
|
#10
|
|
DriverHeaven Addict
Join Date: Dec 2002
Posts: 259
|
Russ, I have made the class modification, and it works. This is incredible
Only one thing:
I was wondering why there was 3 warnings with fisrt line of MyEdit.h. And looking at it I see 2 spaces that may cause the warnings (I suspect that HTLM is making a mistake with those large words). Deleting them it works. But I see too 2 spaces in the second line, and it seems to not have any influence if I delete or preserve them. ¿Could you please confirm me what to do with those spaces that I see in your post?.
About this new plugin, it is not only a low resource alternative to Dynamics Processor: It has less functionalities. But yes, this new plugin will have a low resource version, with practically the same functions, but less precise (very seemed to APS compressor).
|
|
|
Aug 31, 2005, 11:46 AM
|
#11
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
Regarding the spaces, that is a bug with the code tags with this message board. It does not always work correctly. There should be no spaces at all in the first 2 lines (except right after #if and #define).
|
|
|
Aug 31, 2005, 10:37 PM
|
#12
|
|
DriverHeaven Extreme Member
Join Date: Jan 2005
Posts: 4,104
|
Quote:
|
Originally Posted by eyagos
About this new plugin, it is not only a low resource alternative to Dynamics Processor: It has less functionalities. But yes, this new plugin will have a low resource version, with practically the same functions, but less precise (very seemed to APS compressor).
|
Yeah, I understood that from your first post.
|
|
|
|
|
|