|
If I inherit a class B from class A virtually, like this:
class B : virtual A{
};
then I presume, instance of B will contain a vbptr. My question is, where this vbptr will point to, or in other words, what is assigned to vbptr ?
Will it be pointing to the base class object A / to a virtual table ??
Can anyone tell me how vbptrs are implemented under the scenes.
|
|
|
|
|
Answer from a non-guru: Classes in C# can not inherit from other classes using the keyword "virtual". Virtual can only be used for methods and properties, which in turn will create a vtable (or similar construct) behind the scenes.
|
|
|
|
|
Does anybody can help me???
While working my programm throw an Exception which i couldn't catch. The details are following:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.ChildWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
after pushing Continue all working as well as erlier...
Was anybody cross with it???
|
|
|
|
|
I've had the same exception, and I think is something related with threads, but can't find a solution...
Free your mind...
|
|
|
|
|
I have tried in vain to try to navigate through a word table using C# and try to retrieve the style associated with each cell in the table.
I am writing a program that searches each table in a Huge word document for cells of a particular style: "Table: Recording List", but no matter what I try I cannot isolate the cell style.
Any help would be appreciated.
Thanks
|
|
|
|
|
There is no style property for a cell inside a table.
Instead, try using Cell(x,y).Range.Style which will return the style of the Cell.
Otherwise you can select the cell and use Selection.Style.
Either the Selection or Range object will give you the style.
Hope it helps!
|
|
|
|
|
Is it possible and how to realize it?
|
|
|
|
|
Print it out, then staple it together (all 20, very important), then scan it into a single page pdf.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
|
I am writing a print option in a project, and the coding of printpreviewdialog, pagesetupdialog, etc are done. However, I don't know how I can get the current and total page number. Can someone please give me some ideas? (I tried '%p', but it doesn't seem right.)
Also, the printout needs to add certain headers and footers automatically (but not from user input). Can someone please give me a clue how I can get started? It's like the URL, date, etc on a printout from a web browser, but my project is not web application.
Thanks so much for any help!
|
|
|
|
|
Hi. I am in a uni course, and so far, have only been taught the bubble sort. Is there a more effient sort? And if so, what is the syntax? You dont have to give me exact code, just anything I can understand.
|
|
|
|
|
there are a lot different types of sorting and there are trede-offs like memory and time. here is the link which has the description of some popular sorting algorithms:
http://linux.wku.edu/~lamonml/algor/sort/sort.html
|
|
|
|
|
Most sorting operations are implemented using the quick-sort algorithm. Take a look at the Array.Sort() method, which most likely is implemented this way.
|
|
|
|
|
I've been digging deep into research for a couple days (roughly) on this and could use some help. Basically, I need to implement overlays in a ListView. The SysListVew32 (common control) supports it, but they didn't wrap this functionality in .NET so I plan on deriving my own (adding a few more things along the way) and I want to expose this functionality in a ".NET-like" manner.
The problem is that the docs are cryptic and there literally is NOT much help when googling. Seriously, try searching for "ListView LVIS_OVERLAYMASK" and you get 3 pages of hits, with only a couple hits containing any use of the mask (others are just needlessly defined constants).
So, the docs say to use ImageList_SetOverlayImage. What exactly is this doing? I give it a handle to the ImageList (no problem there), a 0-based index to an image (?) and a 1-based index to an overlay mask (?). The docs also state that both large and small image lists can contain overlays. With these two "helpful" tidbits in mind, can I infer that the overlay icons are in the ImageList itself? Where (at what index)? I've dug into the ImageList_SetOverlayImage function but it doesn't help.
Has anyone worked with overlay icons in a ListView? Can anyone else interpret the docs for said methods / constants? I mean, I've been working with the PSDK (and whatever it was called before) since the early 90's and I've never scratched so much hair off my head!
Anyway, I post this here because I want to do this in C# (extending our current class library). TIA
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
I want to expose this functionality in a ".NET-like" manner.
You can derive the ListView class, or the ListViewItem class. I would also consider implementing IExtenderProvider instead since winforms are by design a bit cloaked. Nice article from Esposito in this month's MSDN mag.
Heath Stewart wrote:
So, the docs say to use ImageList_SetOverlayImage. What exactly is this doing? I give it a handle to the ImageList (no problem there), a 0-based index to an image (?) and a 1-based index to an overlay mask (?).
Looks odd but you don't have to mind. The function creates a new image in the image list by taking the passed image index, applying transparent background to it and have that image ready to use. Any time this masked image has to be used, you need to pass his index to the ImageList_Draw method (which you don't actually do if you are using a listview where you have already attached an image list ; things would be nicely taken care of in due time), and since you don't know the index of this masked image, you have to use a macro : INDEXTOOVERLAYMASK(i), where i is the index of the original non-masked image.
From your point of view, you end up creating a list view, attaching an image list to it, and then explicitely setting an overlay image to an arbitrary list view item by setting the item state. Basically with C# you would use the ListView.SetItemState(int nIndex, int nState) method, unfortunately it's internal. I think you are better off sending a Windows message instead, which is anyway what ListView.SetItemState does in the end.
// sequential layout
struct LVITEM
{
... // TODO : setup the struct
}
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
public const int LVM_SETITEMSTATE = 4139;
// in listview report mode only
SendMessage(listview1.Handle, LVM_SETITEMSTATE, nIndex, lvitem);
To set the overlay image, you need to appropriately fill the state field in the LVITEM structure. Only bits 8-11 are useful for the overlay. Again, the INDEXTOOVERLAYMASK macro found in commctrl.h does all this dirty bit work.
Finally, regarding overlay images, they are images that are drawn on top of item images. They differ with item images in that overlay images are masked images, i.e. a mask is applied to filter out all background color first (the color is defined when the imagelist is created).
Hope this helps.
RSS feed
|
|
|
|
|
Actually, I (mostly) know all that. I've also written overlay icons for the shell. The concept is nothing new. As I said, I've been programming with the PSDK for many, many years but haven't gotten quite so deep into custom drawing a control.
One thing you said is what concerns me (since you seemed to have confirmed it). ImageList_SetOverlayIcon actually overlays the icon I specify onto the other icon (lets call it the background icon) and adds that to the image list? Ouch. I could've done that manually in my current implementation (which uses SHGetFileInfo to get icons and file type descriptions) but that could be very memory intensive. I'm guessing that this isn't the solution, then.
I figured that the overlay was only added to the icon during paint operations. Am I missing something, here. I do know from my shell extension that the icon overlay is drawn per-item (even though the item has the same icon), or so it seemed. And since the shell uses all the same classes (SysListView32 and all it's messages / notifications / structs / etc.), I figured the same.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Okay, I've been thinking about this more and perhaps am thinking too much because I've confused myself ( I think )
First, are the icon overlay images (just overlays) stored in the same image list as the large and small images, or a different one initially. Second, are the overlays actually applied to the primary (background, as I think I called it in the previous message) image in the image list?
With these two questions answered, then the next question becomes: does the LVITEM.state (bits 8-11) hold the overlay imageindex or the overlay imageindex applied to the primary image?
I was planning on deriving from ListView of course, and then handling the OCM_NOTIFY message (didn't even remember the reflected messages, since only child controls like the header would send WM_NOTIFY ). For the CDDS_ITEMPREPAINT flag I would set the LVIS_OVERLAYMASK in LVITEM.stateMask and then the bit-shifted overlay image index in the LVITEM.state field, right? I take it that the ListView will draw this automatically since it is set appropriately? I'm confused on that one because it seems to me that it would (otherwise, why are those bits there and used?), but the one or two examples I found via google are doing the custom drawing themselves.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
The names of the Columns in the ListView I have created are wider than the individual col. How can I make sure that the complete col name is displayed without increasing the width of every column ?
Either by increasing the height or wrapping the column names. But I don't find any property that does that !
Thanks,
Paul
|
|
|
|
|
And you won't. You're going to have to override WndProc and delve into this with P/Invoked (and redefined structures), utilizing lots of stuff from the Platform SDK. Believe it or not, all the Windows-like controls you see in System.Windows.Forms are actually the Common Controls themselves and the Windows Forms assemblies use P/Invoked code (and redefined structures, messages, etc.) HEAVILY. Now you'll have to, too!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
How about aligning the text that's shown in the ListViewItems to right or center ?
Can that be done !?!
|
|
|
|
|
While aligning text in the header is easy (ColumnHeader.TextAlign ), you'll once against have to override WndProc to do this. Once you do that, handle WM_CUSTOMDRAW, and redefine a few PSDK structs (like LVITEM), this is actually pretty easy.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
[edit]Forget what's below, this is not intended to do a column header wrapping, but only to auto-fit the width of header columns[/edit]
Instead of creating columns by passing a positive integer, pass -1 to it.
Namely, instead of writing :
listView1.Columns.Add("Very very large column name",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Columns.Add("col2",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Items.Add( new ListViewItem("My Item1"));
write :
listView1.Columns.Add("Very very large column name",-1,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Columns.Add("col2",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Items.Add( new ListViewItem("My Item1"));
And see how column 1 is nicely wrapped to adapt the content in columns.
PS : for your info, -1 is constant LVSCW_AUTOSIZE = -1 declared in commctrl.h
RSS feed
|
|
|
|
|
Hi,
My Question Is: with regards to XML in a C# context.
For the record, I'm using VS 2002, running Win2000 dayly updated, cel400mhz,192ram,dotNET1.1
The Premices:
Put simply, I am trying to use XML as a relationnal database for an application.
I figured an XML schema, an XML file, and some code to plug it in and that was it.
The application is to store contacts information and more types of info
as we upgrade it. So what makes sense here is to have an XML file for each type of info.
The user needs to be able to do the usual, such as view, add, modify, delete entries.
The XML files should reside in the main application folder. Now, this is part of what I tried:
-please bare in mind I'm kinda new with xml...
The Faulty Code:
string item;<br />
XmlDocument myDoc = new XmlDocument();<br />
<br />
myDoc.Load(Application.StartupPath + "\\Contact.xml");<br />
<br />
XmlNode myNode = myDoc.FirstChild;<br />
item = myNode.FirstChild.InnerText.ToString();<br />
txtFirstName.Text = item;
The Error Message:
An unhandled exception of type 'System.NullReferenceException'
occurred in Orchus_temp.exe Additional information: Object reference
not set to an instance of an object.
The Question Redux:
" How do I add, modify, view and delete data that is stored in an XML file and rendered in a C# application? "
I propose to write an article about the resolution of theses issues, since a
lot of people have to resolve these kind of problems, I believe.
So feel free to respond extensively as this will be the substace of my first article!
Thanks!
Antoine Dubuc
Montreal, Canada
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
You can try generate a TypedDataset from the schema
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
myDoc.FirstChild; is the problem.
this is not a safe way to read an XML file - the first child could be a processing instruction...
you are better of using SelectSingleNode(xpath);
where xpath is the thing you want - in you case I'm guessing its "/contact/firstname" depending on you xml file structure...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|