|
I havejust begun to program, but only minor things. Mostly i read about sites for help but they just confuse me. Even the beginner C# tutorials here confuse me. This is mostly because of the words and the format. Some expect you to be already familiar with C++, and i am not. If someone could give me some advice of a site to go to, or any information that could possibly help me progress in the ways of C#.
I never think of the future.It comes soon enough
**Albert Einstein**
|
|
|
|
|
Monkey De Lufy: Pirate King wrote: If someone could give me some advice of a site to go to, or any information that could possibly help me progress in the ways of C#.
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello All,
I am using visual studio .net 2003 c++.
I am trying to get my datagrid to auto resize its columns automatically
using the following code from:
www.hanselman.com/blog/PermaLink.aspx?guid=f3e94fab-335d-497f-8340-9c4ae8e02fa3"
This is his take on the subject and how to do it:
If you double click on the little splitter between columns they will autosize. Therefore, the code to autosize has been written for me; no need to measure strings, etc. How do I force a double click? No, wait, wrongheadedness, how do I call whatever THEY call when a double click happens? So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize.
private void dgLogging_DataSourceChanged(object sender, System.EventArgs e)
{
try
{
Type t = dgLogging.GetType();
MethodInfo m = t.GetMethod("ColAutoResize",BindingFlags.NonPublic);
for (int i = dgLogging.FirstVisibleColumn; (i <
dgLogging.VisibleColumnCount); i++)
{
m.Invoke(dgLogging, new object[]{i});
}
}
catch (Exception ex)
{
System.Diagnostics.Trace.Write("Failed Resizing Columns: " + ex.ToString());
}
}
To tell you the truth I have been away from programming for over a year and I was using viusual c++ 6 at that time so .net is new to me and sure don't understand reflection that well. As to the statement above "So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize."
I don't understand how I can find this method. What I have done is entered this code in order to see all the methods in my datagrid and can find nothing on ColAutoResize.
Type* typ = this->dataGrid1->GetType();
MethodInfo* mi[] = typ->GetMethods();
int MethodCount = mi->Count;
for (int i = 0; i < MethodCount; i++)
{
listBox1->Items->Add(mi[i]->Name);
}
By the above statement,"So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize."
Can someone tell me if I'm looking in the right place for this method or how
I can reflector into DataGrid.OnMouseDown.
Thank You.
RSW
|
|
|
|
|
Hi
Please could someone help me to convert the following to Visual Basic.. It is a CRC16 algorithm using the polynomial (x16 + x15 + x2 + 1) used for very short strings.
Tks
Richard
static unsigned BitsSet (unsigned char ch)
{
unsigned n;
n = 0;
while (ch)
{
n += (ch & 1);
ch >>= 1;
}
return(n);
}
unsigned CRCof (const char *message, unsigned len)
{
unsigned i;
unsigned crc;
unsigned char k;
crc = 0;
for (i=0; i<len; i++)
{
k = (unsigned char)(message[i]) ^ crc; crc = (crc / 256) ^ (k*128) ^(k*64);
if ((BitsSet(k) & 1) != 0)
crc ^= 0xC001;
}
return(crc);
}
|
|
|
|
|
I have an Intenet Explorer toolbar and I want to display a bitmap on it. I used the button separator to make room for the control in the toolbar and I can display text in the CStatic, but when I try to display an image the whole CStatic is painted with a single color. I think it is the first pixel color of the bmp.
I use the following code:
//in the header file:
<br />
CStatic anonTitle;<br />
//in the cpp file
<br />
anonTitle.Create("",WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
<br />
CBitmap anonPic;<br />
anonPic.LoadBitmap(IDB_BITMAP3);<br />
anonTitle.SetBitmap((HBITMAP)anonPic.m_hObject);<br />
anonPic.Detach();<br />
If I use the code from a MFC application it works. But in the toolbar the whole static is painted with only one color.
I have also tried with :
<br />
anonTitle.Create("",WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
anonTitle.SetBitmap( ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP3)));<br />
and
<br />
CString str;<br />
str.Format(_T("#%d"), IDB_BITMAP3); <br />
anonTitle.Create(str,WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
and still same result.
Desperate help needed.
Best regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
class AAA
{
public:
virtual int test()=0;
virtual ~AAA(){std::cout<<"~AAA"<<std::endl;}
protected:
private:
};
class bbb
{
public:
="" virtual="" int="" test()="0;
//If" the="" destructor="" is="" not="" virtual,="" there="" a="" runtime="" error="" which="" will
="" terminate="" program.
="" i="" don't="" know="" why,="" though="" wrong="" called.
="" ~bbb(){std::cout<<"~bbb"<<std::endl;}
protected:
private:
};
class="" ccc="" :="" public="" aaa,public="" {return="" 1;}
="" ~ccc(){std::cout<<"~ccc"<<std::endl;}
protected:
private:
};
int="" main(int="" argc,="" char*="" argv[])
{
="" bbb="" *pbbb="new" ccc;
="" std::cout<<pbbb-="">test()<
|
|
|
|
|
|
I'm sure that you have a question of some degree in relation to the code you posted. I figure that you have a question about virtual destructors in relation with multiple inheritance, but please hint me, where is your question?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
The question is hidden in one of the comment ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I generally skip illustrations until I've read the question..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote: but please hint me, where is your question?
as his question was hidden, i was also asking for it with criticism and "hidden style" too
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I think that people should take more time to post a clear question, instead of hiding it in something that is supposed to be an inllustration.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Why will the program be aborted, when ~BBB() is not virtual?
|
|
|
|
|
Hello,
I think that when the runtime destroys your object, it sees that it is instantiated from multiple classes (the inheritance). The runtime then starts to look for all appropriate destructors in the virtual function table. This is done because the runtime must call more than one destructor. When the runtime detects that one of the destructors is 'missing' in the v-tables, it crashes since it doesn't know what to do.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Yeah, if you don't have virtual destructors, then your delete better be to a pointer of the proper class allocation.
For example, with ~BBB non-virtual, this will not crash:
CCC* pbbb = new CCC;<br />
delete pbbb;
So, if you can't afford virtual destructors, then you better cast your delete operation to a pointer of the correct type.
For example, with ~BBB non-virtual, this DOES NOT crash:
BBB* pbbb = new CCC;<br />
CCC* pccc = (CCC*)pbbb;<br />
delete pccc;
|
|
|
|
|
Hi
Please could someone help me to convert the following to Visual Basic.. It is a CRC16 algorithm using the polynomial (x16 + x15 + x2 + 1) used for very short strings.
Tks
Richard
static unsigned BitsSet (unsigned char ch)
{
unsigned n; n = 0;
while (ch)
{
n += (ch & 1);
ch >>= 1;
}
return(n);
}
unsigned CRCof (const char *message, unsigned len)
{
unsigned i;
unsigned crc;
unsigned char k;
crc = 0;
for (i=0; i
|
|
|
|
|
When you click on a Dialogs title bar what event is triggered? How does one detect if the title bar has been clicked?
thanks,
sb
|
|
|
|
|
WM_LBUTTONDOWN is sent for sure, maybe WM_NCHITTEST ca nbe intercepted (check for OnNcHitTest whose return value is HTCAPTION when the title bar was clicked). To be sure, try with Spy++,
~RaGE();
|
|
|
|
|
I am creating an edit control like this .....
editPointSize.Create(ES_CENTER|WS_VISIBLE|WS_CHILD,rectOffScreen, this, ID_EDIT_POINT_SIZE);
Then I am setting up the text in it like this .....
CString strData;<br />
strData.Format("%d", nPointSize);<br />
editPointSize.SetWindowText(strData);
If I run this under the debugger its OK, but if I compile and run a release version it crashes, any ideas?
Many Thanks,
Ali
|
|
|
|
|
Alison Pentland wrote: if I compile and run a release version it crashes
what is the error message when the application crashes please ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 9:57 Tuesday 8th November, 2005
|
|
|
|
|
Thanks for the interest, the error is,
First-chance exception in PEA Plus.exe: 0xC0000005: Access Violation.
Cheers,
Ali
|
|
|
|
|
Alison Pentland wrote: editPointSize.Create(ES_CENTER|WS_VISIBLE|WS_CHILD,rectOffScreen, this, ID_EDIT_POINT_SIZE);
Does this always succeed ? Try and messagebox its result.
~RaGE();
|
|
|
|
|
Alison Pentland wrote: I am creating an edit control like this .....
editPointSize.Create(ES_CENTER|WS_VISIBLE|WS_CHILD,rectOffScreen, this, ID_EDIT_POINT_SIZE);
Why are you creating the control at runtime rather than design time?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Reply to Rage (CP very very slow & I can't seem to reply to the correct message!)
Great idea, here's the code I tried...
if(editPointSize.Create(ES_CENTER|WS_VISIBLE|WS_CHILD, rectOffScreen, this, ID_EDIT_POINT_SIZE))<br />
AfxMessageBox("Edit OK");<br />
else<br />
AfxMessageBox("FAIL FAIL FAIL!!!");
It always returned TRUE, 'Edit OK' and still crashed when I did SetWindowText.
Thanks for the help, I'm not sure what to do next, so if you have any more ideas they will be gratefully received.
Cheers,
Ali
-- modified at 11:37 Tuesday 8th November, 2005
|
|
|
|
|
Erm, good question.
I am using MFC VC++ 6, and creating the edit box in the view window. I always create controls in dialog boxes at design time but I always create them in the view window at runtime. I have always done it that way, not sure if its right but it normally works. To be honest I don't know how else to do it, the designer thingy is only for dialog boxes isn't it?
Thanks for the input, any suggestions gratefully received
Ali
|
|
|
|