|
Thanks!
But can this be done using OLE drag and drop?
If so, how do I do it?
Can't seem to find any good information of how to drag Controls.
Thanks!
|
|
|
|
|
No. You cannot..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi Guys,
I hope someone here knows more about managed c++ than i do.
The problem: I get a char* from a structure, and i need to convert it to a String*(or a Stringbuilder). The way i do it is hopelessly inefficient. Is there any way to improve on this.
<br />
Mail *mail = new Mail();<br />
<br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String = new String(struct[a].subject,0,struct[a].subjectSize); <br />
}<br />
What i'd like to do is some thing like this. But i dont know how.
<br />
Mail *mail = new Mail();<br />
mail->String = new String( <br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String =
}<br />
Thanks
|
|
|
|
|
Hello,
I don't know what you are trying to do here, but you initialize the mail object a 1000 times and in the end it will only hold the last element.
Let me get the case clear here: you have an array of 1000 structures and one mail object. You want 1000 email objects initialzed with each of the structures. Right?
So please describe your problem a little better, because now it doesn't make much sense to me.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi Bob,
Thanks for the reply. I'm creating only one instance of the Mail object. In each iteration I instantiate a new String from the char*
I got from mailStruct[a].subject, and I raise an event (The mail object is processed on the other side).
<br />
Mail *mail = new Mail();<br />
<br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String = new String(mailStruct[a].subject,0,strlen(mailStruct[a].subject)); <br />
MailEvent(mail);<br />
}<br />
A new String* instance is created with each iteration. This translates into a new memory allocation on each iteration and more work for the garbage collector.
So i'd like to change the code so that i create only one new String.
<br />
Mail *mail = new Mail();<br />
mail->String = new String (
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String =
MailEvent(mail);<br />
}<br />
|
|
|
|
|
ok, I think I get it, you more or less want to send a 1000 email with different strings ?
I think your on the right track with your second example.
is the Main object you own ? does it allocate the String object when it gets constructed ?
I would change the definition of the String member to not be dynamically allocated; if not, you will need to allocate it like you do before the loop.
if the String is a build-in type of the managed c++ language, just assign it a new string in the loop should remove the old one and put the new one in;
Be certain that if you allocate it with new, that youp delete it ( or not, it might be collected later ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You're spot on. Thats exactly what i'm doing.
I defined the Mail as a managed struct and it contains a bunch of managed c++ Strings.
The Mail struct doesn't allocate the String when it's constructed. (This is exactly what it looks like)
typedef __gc struct Mail
{
String *entryid;
String *tempid;
String *storeid;
String *subject;
String *fromName;
String *fromEmail;
}
The String is "newed" with every iteration. You're right, the garbage collector should take care of this. But why put the garbage collector under strain, when it may be unnecessary.
How can i allocate the memory for the String only once? But change its value a 1000 times?
|
|
|
|
|
Since string is a class, it must have member functions. So, you should be able to use those to alter it's contents. The most logical thing would be that operator = is implemented to replace the contents with something else.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello guys,
i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize.
The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize.
I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem.
Anyone got some suggestions
Thanks Remco
|
|
|
|
|
How are you handling the OnEraseBkgnd message?
I would recommend something like this:
BOOL CYourDialog::OnEraseBkgnd(CDC* pDC)
{
static int controlsNotToBeErased[] =
{
IDC_REFINE_BUTTON,
IDC_SCRIPT,
IDC_AUTOCLIP,
IDC_CLIP,
IDC_REFINE_CONFIG,
IDC_SCRIPT_SETUP,
IDC_SUPPRESS_CO2,
IDC_SUPRESS_WATER_CAPACITY,
IDC_SET_COMBO,
IDC_REFINE,
IDC_GRAPHS,
IDC_REFINEGRAPH,
IDC_CO2CHECK,
IDC_CO2,
IDC_SOLUBILITYCHECK,
IDC_SOLUBILITY,
IDC_VOLATILITYCHECK,
IDC_VOLATILITY,
IDC_GLPKA
};
CRect clip;
pDC->SaveDC();
for (int i = 0; i < sizeof(controlsNotToBeErased) / sizeof(int); i++)
{
CWnd *pWnd = GetDlgItem(controlsNotToBeErased[i]);
if (pWnd && pWnd->IsWindowVisible())
{
pWnd->GetWindowRect(&clip);
ScreenToClient(&clip);
pDC->ExcludeClipRect(&clip);
}
}
pDC->GetClipBox(&clip);
pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
pDC->RestoreDC(-1);
return FALSE;
}
This should hopefully reduce contro flicker etc.
If you vote me down, my score will only get lower
|
|
|
|
|
The problem is all of the painting that's going on as you move each control. Try looking at the DeferWindowPos [^] API function, which lets you change the position of several windows and then update the screen all at once.
Software Zen: delete this;
|
|
|
|
|
thanks for the fast replies, i will try your suggestions
|
|
|
|
|
Hi all!
I created a file DLL by VC++.After that to insert in VisualBasic I do following:
From Menu choose Project->Reference...-> Browse to file *.DLL (Adsoft.DLL)
Choose in ComboList (Prọect/Library)->Adsoft
But any class and function in there don't to appear.
If possible. Can you give me an example ?
Thank !
|
|
|
|
|
Thangnc wrote:
But any class and function in there don't to appear.
Have they been exported?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks DavidCrow!
I don't think your ? I write this class following:
// Adsoft.H
#ifdef ADSOFT_IMPL
#define CLASS_DECL_ADSOFT _declspec(dllexport)
#else
#define CLASS_DECL_ADSOFT _declspec(dllimport)
#endif
#undef AFX_DATA
#define AFX_DATA CLASS_DECL_ADSOFT
class AdsoftDLL : public CSocket
{
public:
BOOL CGetCheckErro(int nErroCode);
};
#undef AFX_DATA
#define AFX_DATA
// Adsoft.cpp
#include "afxdllx.h"
#include "Adsoft.h"
BOOL CGetCheckErro(int nErroCode)
{
if (nErroCode==0)
return FALSE;
return TRUE;
}
But to happen phenomenon don't to want
|
|
|
|
|
I'm really not sure what you've provided here. Is this code that does not work? Are you wanting to export the AdsoftDLL class or just the CGetCheckErro() method? After a successful compile/link, have you verified with either Dependency Walker or Dumpbin that the DLL has the correct export table?
Thangnc wrote:
BOOL CGetCheckErro(int nErroCode)
In adsoft.cpp, shouldn't this be:
BOOL AdsoftDLL::CGetCheckErro(int nErroCode)
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
//Hi all,Thank you for helping me!
LPBYTE CString_To_LPBYTE(CString str)
{
LPBYTE lpb=new BYTE[str.GetLength()+1];
for(int i=0; ibr>lpb[str.GetLength()]=0; //????
//How can I code this line?<for....>
return lpb;
}
|
|
|
|
|
try this function :str.GetBuffer(0)
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
Try:
for (int i = 0; i < str.GetLength(); i++
lpb[i] = str[i];
lpb[i] = '\0'; or:
_tcscpy(lpb, str);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi,
Do not use _tcscpy() function, because CString is a class, it doesn't mean it is allocating one extra byte for '\0' NULL character to say end of string.
And also avoid lengthly for loop while causes poor performance..
Use this method..
LPBYTE CString_To_LPBYTE(CString str)
{
LPBYTE lpb= NULL;
int nLength = str.GetLength();
if (nLength > 0)
{
// If you need space for NULL allocate one more. otherwise don't
lpb = new BYTE[(nLength + 1) * sizeof(TCHAR)];
memcpy(lpb,str.GetBuffer(0),(nLength) * sizeof(TCHAR));
lpb[nLength * sizeof(TCHAR)] = 0; // only if you need NULL at end
}
return lpb;
}
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
S.Gopalakrishnan wrote:
_tcscpy() function, because CString is a class, it doesn't mean it is allocating one extra byte for '\0' NULL
_tcscpy does copy the terminator, since the CString argument's LPCTSTR conversion operator is guaranteed to create one.
Software Zen: delete this;
|
|
|
|
|
Thank you so much everyone! but there is still problems!
I used Mr S.Gopalakrishnan's method but there is
Linking error:
System.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall System::CString_To_LPBYTE(class CString)" (?CString_To_LPBYTE@System@@QAEPAEVCString@@@Z)
Debug/ex_ShutdownWindows.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
How can I resove it? Thank you!
|
|
|
|
|
is there any possibility to use this macro in Visual C++ .NET. I have tryed everything but compiler simply doesn't recognize the macro.
CRPG, FRPG, Oblivion Fan
Hater of Counter Strike ( i hate it soo much damn it );
|
|
|
|
|
If the predefined macro doesn't work, you can always write your own.
#define TRACE(x) (System::Diagnostics::Debug::WriteLine(x))
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
cpprules wrote:
I have tryed everything but compiler simply doesn't recognize the macro.
Isn't it still in afx.h ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|