|
A glyph for character \u0633 (1587) does exist in the Tahoma font, hence the ? like I said earlier. If there's no glyph for a particular font, then you'll have to use a different font or use an image with the text, but then it's pretty static.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I Get a datatable from Database's someting table at first, then, some time after, I Get a datatable from database's same table.In my programe,I want to know this table's all records if changed. Do have some good method?
|
|
|
|
|
You can use DataSet.Merge(DataSet, bool) to merge the two DataSet s and preserve the changes. You then call DataSet.GetChanges on the same DataSet you called Merge on, and enumerate through the table(s), then enumerate the rows and check DataRow.RowState .
If you call DataSet.AcceptChanges or DataTable.AcceptChanges , these changes will be lost (the rows are resolved according to their state). Calling DataAdapter.Update on the DataSet or DataTable will call this method automatically.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an idea to submit an article about a system to license components. Since I have looked all over and have not been able to find much of real use in this area elsewhere I figured that I might as well share the knowledge a bit here since I have gotten so much from the site.
My problem is this… The code has a few issues (for lack of a better term ) that I just cannot seem to get ironed out. Not that I am not trying mind you, I just have not been able to figure it out yet. The question is this. Is it considered good (or just even ok) form to post an article that has 'issues' in hopes that:
1 - Others will benefit form the code
2 - Others might help locate what the heck I am doing wrong?
I hate to add to the chaff of the site by posting an article that will just end up confusing people in the long run.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
As a former CodeProject editor (didn't have the time anymore) and current Protector, I can assure you there's much worse articles. I'd say go ahead and post it, but make sure you point out what the problems are. Don't forget to update your article (with a history of changes at the bottom; read through some existing good articles for examples) when you've solved it and make sure you read comments in your article's forum (you should get an email automatically when anyone posts a message to your article's message board).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've subclassed two classes inside classA. Theses subclasses are derived from classA. There are some virtual functions in classA with their implementation defined in those subclasses. Client can only see classA. Instances of classA will be created by a class factory. On basis of parameters passed to class factory, the factory creates new objects of subclasses and returns them to client. Following snippet demonstrates the idea.
<br />
public class classA<br />
{<br />
<br />
<br />
<br />
internal class subclass1 : classA<br />
{<br />
<br />
}<br />
<br />
internal class subclass2 : classA<br />
{<br />
<br />
}<br />
} <br />
1) I want to run subclass1 objects into COM+ transaction. Is it possible because client never sees subclass1 although it uses subclass1. If possible how ??
2) Is it a good practice to do things this way. The idea behind was to provide client smplicity of using one class while acheiving the logical seperation at the backend for developer's ease.
Thanks in advance,
Regards,
Hatim Ali.
|
|
|
|
|
In the System.Dialognise namespace there are many classes helping detect system error.
Now i have a big problem: Does there have a possibility to detect error from application software ?
For example, can i get a message while my office word.exe facing an error(any type of error) ?
|
|
|
|
|
Hi,
I don't know why I can' use Environment.SpecialFolder in my program.
Is it not support by Framework 1.0 ?
If not support in 1.0, then how can I get the desktop and MyDocument folder path ??
Thanks
|
|
|
|
|
You can use it. But Visual Studio 2003's Intellisense doesn't show it. You'll have to code it without the aide of Intellisense, it'll compile fine.
#include "witty_sig.h"
|
|
|
|
|
Hi
I am using C# (VS2003). I want to create an usercontrol having entry forms (ie. customers, suppliers, orders etc...) which then, I can use with a Windows Form and call New, Delete, Update, Next, Prev, Last, First, Print methods on an usercontrol within a form. Basically I want to create a base_usercontrol and base_form having some common loosly coupled methods to interect with each other. And Later on I can inherit base_usercontrol for real entry and base_form for real form operations.
I read some artical many times ago but can anyone have more information on this?
Thanks in advance
|
|
|
|
|
I am just looking a good C# example of grouping a list of data by "Date Groups" like Microsoft does in Outlook 2003 Inbox where e-mail is grouped by "date terms" like "Today", "Yesterday", "Tomorrow", "Two Weeks Ago" etc...
I started embarking on this code myself but it got complicated quickly so I thought someone smarter than me must have already tackled this one and posted a good article on how to do it somewhere - anyone know of one??? Thanks in advance!!!
|
|
|
|
|
If you're willing to wait for .net 2 then ListView has grouping ability in there.
|
|
|
|
|
Actually doing the "groups" in the ListView is not a problem (I am using Infragistics Grid Control and grouping by dates is easy…) but what I need is the function which accepts in a date, and returns a string for "Yesterday", "Tomorrow", "Last Month", etc... I know it sounds easy, but it gets pretty complicated quickly to do it right and take into account all the possibilities. For example, on the first day of the month, if you send the function yesterday’s date, the function needs to return "Yesterday" not last month. Same thing for first day of the year etc… Anyway, whenever I run into something even slightly complicated, I always figure someone smarter than me has already written some very elegant and efficient code to handle it! MS has this code for Outlook, just wondered if anyone had replicated it in a good C# example.
|
|
|
|
|
You could probably adapt
http://www.codeproject.com/cs/miscctrl/GroupListView.asp#xx824943xx
Gary
"I invented the internet".
- Al Gore, former U.S. Vice President
|
|
|
|
|
I want to underline only the first letter of text on a button control.
I don't want to use an '&' because I am--for what ever reason--using alt keys for the short cut keys for this button.
ie
this.button1.Text = "Close";
The 'C' needs to be underlined
and the short cut key is Alt-C.
thanks
|
|
|
|
|
For one, instead of hooking up shortcut keys (however you're doing that, since there's a myriad of ways), why not just use "&Close" since you're assigning Alt+C to the button? It seems a logical choice.
Really, the only other way is to owner-draw the button, but this would be tedious for such a simple requirement. Extend the Button class (encapsulating this functionality in a derivative class lets you reuse this new Button derivative without duplicating the painting code all the time in container controls) and override OnPaint . From there, there's many things you could. You could decide to paint the entire thing yourself (i.e., don't call base.OnPaint ) or call base.OnPaint first, then fill the inner portion of the control with the BackColor (so no text is shown).
Then, use the Font to create a new Font with the FontStyle.Underline style set. Use PaintEventArgs.Graphics.MeasureString to get the bounds for the first character ("C"). You'll need this shortly. Then draw the "C" with that Font . Then, using the Right property of the RectangleF you got from the first call to MeasureString , draw the rest of the text ("lose") with the original Font (the one defined on the control, since the Font for "C" is only temporary, though you might consider caching it and updating your cache in the OnFontChanged event handler for performance reasons).
This is quite a bit of work (not difficult, but tedious) for something that can be done simply with "&Close", especially since that would already use the same shortcut as what you're assigning already (unless you mean Alt+C is mapped to something else).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want one instance of an application (let's call it instance2) to get another instance (instance1) of the same application.
Instance2 already has the handle of instance1 - I've checked, and the handle's match. But in instance2, if I do :
IntPtr hdlInstance1 = [whatever I do to get the correct handle];
Control myInstance1 = Control.FromChildHandle(
hdlInstance1
);
then myInstance1 is always null. I can use Control.GetHandle(hdlInstance1) as well - that doesn't work either. Is there some special way I'm supposed to get instances by handles? I can't find any useful info online. And has anyone noticed how often code sites have the easiest, most trivial examples of a subject, like in this case, how to stop there being more than one instance of an application, but none of the sites will even dare doing something a bit more advanced like actually doing something with the second instance instead of just blocking it? It's almost like code sites just rip eachother off - one site puts up a simple example, then everyone else just copies it.
Sigh .... rantmode off.
Thanks in advance.
|
|
|
|
|
You can't create object references using handles from other processes. You need to P/Invoke SendMessage and send window messages to the other handle. This is documented in the .NET Framework SDK.
You could, instead, use .NET Remoting or some other remote procedure calling (RPC) convention, which may be easier depending on what you need to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What's the desired interraction between the
app instances? One instance "getting" another
isn't very specific. Give a bit more detail
and maybe someone can get you started.
|
|
|
|
|
The exact use is I need to send a string message from one instance to another (the string message being the file name the one instance wants the other one to open). This has to be done from the static Main() method.
The simplified code could be :
// this is the main "starting" class of my app
class MainForm()
{
public static void Main(string[] args)
{
// gets instance of this app already running
MainForm otherAppStance =
objCleverWidget.GetOtherInstance();
// sends message to other instance and quits
if (otherAppStance != null)
{
otherAppStance.TransferMessage(args[0]);
return;
}
}
public static void TransferMessage(string
strMessage)
{
MessageBox.Show(
"The other instance says" + strMessage
);
}
}
So what I really need to know is how to make
objCleverWidget.GetOtherInstance()
This will return the instance of the main Window Form from the other app instance, and all my problems will be solved.
That's the ideal solution. I haven't had any luck coding it, so I came up with a small but crude workaround - use P/Invoke's SendMessage. SendMessage is limited though - you can't send strings with it, just a message id in the form of an uint, and two pointers which I can't figure out properly. So I converted my string message into chars, converted each char to its uint equivalent, and sent those uints as message id's from one instance to another (obviously using some start- and end-message flags). It works and uses very little code, but I'm not too sure how well it will stand up to scrutiny. Oh, and it kinda destroys the recipient app's main form - you have to redraw after receiving messages. Doesn't sound too healthy ...
I've seen two other solutions online, one in VB (on codeproject infact) which I dont understand too well (VB + interop = brainmelt), and the other using Remoting, which raises questions of its own (assumes user pc will have network support). I was surprised by how much code was used in both solutions - my workaround was pretty light.
Anyway, associating an application with a file type is a pretty standard requirement, so I am a little puzzled by the lack of built-in functionality in the .Net framework for this kind of thing. If you can point out a practical solution that doesn't use networking, please let me know. I have reason to believe P/Invoke's SendMessage will do the trick, but I need to find out how to use it's two pointer parameters.
Thanks for your time!
|
|
|
|
|
Okay, I think a more straight-forward solution to
what you want to do, provided both applications
are on the same machine, is to use shared memory
via Memory Mapped Files. C# is a bit of a pain
in that it only gives the PInvoke mechanism for
doing Win32 stuff, but using a page of swap file
in a memory mapped file for shared memory isn't
that difficult. There are a couple articles
showing how to get at memory mapped files from
C# on Code Project. Also you can use the tool
at http://pinvoke.net to pull the prototypes
adjusted for C# right into the editor for you.
The main advantage of using a named memory mapped
file with app instances is that you don't need to
worry about handles. Using a GUID string in the
memory mapped filename makes sure it's unique.
So in your application you try to create the
Memory Mapped File with CreateFileMapping(). If you get a handle but Marshal.GetLastWin32Error() returns ERROR_ALREADY_EXISTS then you're in the secondary instance. Otherwise if the creation
succeeded you're in the primary.
The secondary instance copies info it wants to
send to the primary in the shared memory. The
primary instance reads it out. To avoid mangling
the data you can use a mutex to control access.
Before it quits, the secondary instance gets the
mutex, copies the info to the shared memory,
releases the mutex, then exits(if that's what
you want it to do.) The primary gets the mutex,
checks for new data in the shared memory, if it
finds it then it copies the data out, then releases the mutex.
It sounds a bit more complicated than it is.
I would look for examples of Memory Mapped
Files. Using one page of system swap file
is the simplest case with fewest system
quirks to worry about.
As I suggested, the TellTail component on
www.torry.net does what you're trying to
do. Delphi is pretty Enlish-like so even
if you don't program in it often you can
read the source and get the gist. Besides,
Win32 calls are going to be pretty much the
same no matter what language you call them
with.
|
|
|
|
|
I want to add ComboBoxes to some TreeNodes in a TreeView. I am unable to find a way to do this. Visual C++ 6 allowed this functionality. I am sure they have ported this over to .NET. Is there a way to do this ?
I want the user to be able to select a value from a combobox in a treenode.
Thx!
Regards,
Shardool Karnik.
|
|
|
|
|
You can do this like you would've using the Common Control APIs and Windows APIs, but you need to P/Invoke this functionality. The Handle property (inheritted from Control ) is the HWND .
The TreeView control (like most controls in Windows Forms, and even many other classes throughout the .NET BCL) encapsulates native APIs. Most of the Windows Forms controls actually wrap the common controls, so the TreeView wraps the Tree View common control.
This means that you have to override WndProc and handle the drawing messages (among other custom drawing messages) and site (or position) the ComboBox (which wraps the Combo box common control) in the edit portion of a TreeNode (which encapsulates a TVITEM struct).
Sorry I'm not providing any example code, but this is not an easy subject and is definitely a little too lengthy for the message forums. This would be better suited to an entire article.
You might try searching for such an article here on CodeProject (I've not seen one, but I haven't seen every article on this site neither). You might consider writing an article aobut it if/when (here's hoping for the latter :beef: ) you complete such a task.
If you have specific questions regarding P/Invoke and whatever else you need, don't hesitate to ask here.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi...
Can anyone show me how to changle the color on the statusbar?
i have not tried anything because i dont have a clue!
there is no panels on only pure text!
QzRZ
|
|
|
|
|
You can't simply set StatusBar.BackColor (inheritted from Control ) like you would normally. It is not support and, hence, is hidden.
You instead must add one StatusBarPanel (you can use the designer to do this) that covers the entire StatusBar . Set the Style property to StatusBarPanelStyle.OwnerDraw and handle the StatusBar.DrawItem event.
In your event handler, you can use the StatusBarDrawItemEventArgs properties (like Graphics and Bounds properties) to fill the background.
If you read about the StatusBar.DrawItem event in the .NET Framework SDK (see http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsStatusBarClassDrawItemTopic.asp[^]) you will find an example.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|