|
Hi
I want to dynamic load # buttons.
Like if i have one employee, i only show 1 'Remove' button next to his information.
But when there are 10 employees, i want to see 10 buttons at the correct place.
How can i make a copy of that button and place it somewhere else?
Greetings
jens
|
|
|
|
|
|
Hi David
Ok but the ID given to that CButton needs to be changing, i would make it something like
IDC_BUTTONREMOVENR1
IDC_BUTTONREMOVENR2
...
How can i now use the same code for IDC_BUTTONREMOVENR1 & the others?
Let's assume i have written the correct code for the 1st button on click. But can i use that code now for the other buttons too and how so?
Greetings
Jens
|
|
|
|
|
I don't know what your design is, but I would think an acceptable solution would be to put the employees in a list control with checkboxes in the first "column." Then you would only require one Remove button. Does that make sense?
If that violates your design, you can use something like:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(IDC_BUTTONBASE, IDC_BUTTONBASE + 4, OnRemove)
END_MESSAGE_MAP()
CButton *pRemoveButtons[5];
for (int x = 0; x < 5; x++)
{
pRemoveButtons[x] = new CButton;
pRemoveButtons[x]->Create(..., IDC_BUTTONBASE + x);
}
void CMyDlg::OnRemove(UINT nID)
{
TRACE("You clicked on Remove button #%d\n", nID - IDC_BUTTONBASE);
}
|
|
|
|
|
I think that ON_CONTROL_RANGE would probably be a little simpler to use here, rather than ON_COMMAND_RANGE.
|
|
|
|
|
Whether you provide the BN_CLICKED notification code in the macro or the handler function, I don't see that one is any easier to use than the other.
|
|
|
|
|
Does any one know how to access the help button on a property sheet? I'm trying to use the resource editor, but all it lets me access are the individual pages. Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
hi RalfPeter
You can't access the help button on the property sheet because you can't see the form, and that's pretty ennoying.
Doesn't it work when you add 'OnHelp' (message map) @ header file propsheet?
afx_msg void OnHelp();
void CMyPropSheet::OnHelp()
{
AfxMessageBox("onhelp");
}
Hope this works.
Just Modified
I fixed the problem by not using the standard help button but i created the button myself.
OnInitDialog:
CRect rect, tabrect;
//Get button sizes and positions
GetDlgItem(IDOK)->GetWindowRect(rect);
GetTabControl()->GetWindowRect(tabrect);
ScreenToClient(rect);ScreenToClient(tabrect);
int iWidth = rect.Width();
rect.left = tabrect.left;
rect.right = tabrect.left + iWidth;
m_ButtonHelp.Create("&Help",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_TABSTOP, rect, this, IDC_BUTTON_HELP);
//add IDC_BUTTON_HELP in RESOURCE.H yourself!!
m_ButtonHelp.SetFont(GetFont());
This creates the button + positions it correctly.
Then work with the previous code to catch the onclick.
Greetings
Jens
|
|
|
|
|
Exactly what do you mean by "access the help button?" Are you wanting to respond to the clicking of the Help button? As the property sheet is not based on a dialog template (like the property pages are), you obviously won't be able to alter it via the resource editor. The OK, Cancel, Apply and Help buttons are created dynamically.
See if the MSDN article Q132715 is of any help.
|
|
|
|
|
In my base class I have this (the base class is pure-virtual)
class CBase
{
protected:
bool m_bEnable;
public:
bool EnableMe( bool bEnable ) = 0;
}
and in each derived class, I have
bool DerivedClass::EnableMe( bool bEnable )
{
m_bEnable = bEnable;
}
would it be better to have :
class CBase
{
protected:
bool m_bEnable;
public:
bool EnableMe( bool bEnable ) { bEnable = bEnable;};
}
bool DerivedClass::EnableMe( bool bEnable )
{
CBase::EnableMe(bEnable);
}
Thanks,
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Hi,
it depends on the use of the class.
If you want to impement a interface class, then the pure virtual class should be used.
Keep in mind, that you cannot create instances (aka variables) of this class. Those classes can only be accessed by pointers.
You may write a function body for a pure virtual function, which may be called by any derived class. Resulting in a combination of your to proposals.
G. Steudtel
|
|
|
|
|
Hi,
I have a project that compile with the c2664 error.
error C2664: 'test' : cannot convert parameter 4 from 'void (int,float [],float [])' to 'void (__cdecl *)(int,float [],float [])'
None of the functions with this name in scope match the target type
// functions prototypes
void funcv (int n,float x[],float f[]);
void test (float x[], int n, int *check,
void (*vecfunc) (int, float [], float []));
How can I correct the functions prototypes to get a correct compilation ?
Thanks,
Claude
|
|
|
|
|
You haven't provided enough information. The compiler is not complaining about the prototypes. Show us the code snippet that calls the offending function (i.e., funcv, test).
|
|
|
|
|
Hi,
The function test is called like this:
CBroydn Broydn;
Broydn.test(x,N,&check,funcv);
I have to add that this code was working when I was utilizing thes functions inside a DLL.
Now I want to get out this code from the DLL. and I get this compile error c2664.
Thanks,
Claude
|
|
|
|
|
A hint might be the fact, that the compiler complains about converting a void parameter to a __cdecl function pointer returnig void. Looks to me, that the function prototype of 'funcv' is different. Probably of type pascal or samoething like that.
G. Steudtel
|
|
|
|
|
Show the protypes for funcv.
I think to use class methods as function pointers, you need to make the method static.
Jason Henderson My articles
"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill
|
|
|
|
|
The interface IShellDispatch,has an updated interface named IShellDispatch2.
How to invoke IShellDispatch2 and all the members method.
Swarup
|
|
|
|
|
#define MY_SQL "INSERT INTO MyTable ([fldFileName]) VALUES ('%s')"<br />
sprintf(szStmt,MY_SQL, "Greensleeves.mp3"); <br />
SQLExecDirect(hStmt, (SQLTCHAR*)szStmt, SQL_NTS);<br />
<br />
#define MY_SQL "INSERT INTO MyTable ([fldFileName]) VALUES ('%s')"<br />
sprintf(szStmt,MY_SQL, "Souvenirs d'enfance.mp3"); <br />
SQLExecDirect(hStmt, (SQLTCHAR*)szStmt, SQL_NTS);<br />
Could you help me to fix this bug
thank a lot!!!
|
|
|
|
|
You should really have some sort of DB class that would automatically handle this kind of stuff for you, including replacing NULLs and such. An example would be the following:
int ApplicationInstance::StringReplace(char *cpSearch, LPCSTR cpFind, LPCSTR cpReplace, BOOL bDisableNULLCheck /*=FALSE*/, BOOL bReplaceEmbeddedQuotes /*=FALSE*/)
{
if (!cpReplace || (*cpReplace == 0 && !bDisableNULLCheck))
return 0;
int iRetval = 0;
BOOL bDeleteBuf = FALSE;
char *cpReplaceBuf = (char *)cpReplace;
int iReplaceLength = strlen(cpReplaceBuf);
int iFindLength = strlen(cpFind);
if (bReplaceEmbeddedQuotes && strchr(cpReplaceBuf,'\''))
{
LPCSTR cpQuote = strchr(cpReplaceBuf,'\'');
while (cpQuote)
{
iReplaceLength++;
cpQuote = strchr(cpQuote+1,'\'');
}
cpReplaceBuf = new char[iReplaceLength+1];
if (!cpReplaceBuf)
return -1;
char *cpDest = cpReplaceBuf;
cpQuote = cpReplace;
while (*cpQuote)
{
*cpDest++ = *cpQuote;
if (*cpQuote == '\'')
{
*cpDest++ = '\'';
}
cpQuote++;
}
*cpDest = 0;
bDeleteBuf = TRUE;
}
BOOL bSmaller = (iReplaceLength <= iFindLength);
char *p = strstr(cpSearch,cpFind);
while (p)
{
iRetval++;
// move rest of string so that the replace value fits right in.
if (bSmaller)
strcpy(p+iReplaceLength,p+iFindLength);
else
memmove(p+iReplaceLength,p+iFindLength,strlen(p+iFindLength)+1);
memcpy(p,cpReplaceBuf,iReplaceLength);
p = strstr(cpSearch,cpFind);
}
if (bDeleteBuf)
delete [] cpReplaceBuf;
return iRetval;
}
|
|
|
|
|
Hi,
I'd like to use system command but I don't like it to open console while the command is executing?
or if there is a c/c++ cmd for deleting all files in a directory like -
system("del /q *.*")
thanks
Yaniv
|
|
|
|
|
how about using ShellExecute method........
Swarup
|
|
|
|
|
Use SHFileOperation(). It supports wildcards.
|
|
|
|
|
|
I am having problems using the Adobe Acrobat ActiveX Control. I embed the control in a dialog box but when I try to generate a member variable to hold the control in Class Wizard an error is reported
"The ActiveX Control is not registered properly, or its type library number is incorrect. Try registering the control by removing and importing it in the Component Library"
Unregistering and registering the control doesn't help. So I'm not really sure where to go from here.
I am using Adobe Acrobat 5.0 (both the pdf.ocx and pdf.tlb files are present on my system)
|
|
|
|
|
The ActiveX is designed to make it difficult for you to use in an application. The pdf.ocx is not the real thing - the actual ActiveX control carries names like pdf42.ocx etc.
However, the class Id for the real ActiveX is
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0xca8a9780, 0x280d, 0x11cf, { 0xa2, 0x4d, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
return clsid;
}
Use that in the normal CWnd derived class that the wizard will generate for you to hack it!
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|