|
first:i use two functions to install a new font int the following.
AddFontResource("d:\\tmp\\Ni7seg.ttf");
SendMessage((IntPtr)0xFFFF, WindowsMessages.WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
second:i don't konw how to use the new font.how to set the label's text with the new font?who can give me a example?very thanks
|
|
|
|
|
A label has a font property. You can use that to set the font for the Label text.
|
|
|
|
|
i know that.i mean i have a font file(.ttf),my program first load this font to memcry.
but i don't know how to let the label to display text with the font.
i know one waw can get it.for exam:
System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
pfc.AddFontFile("d:\\tmp\\Ni7seg.ttf");
Font myFont = new Font(pfc.Families[0], 80f, FontStyle.Regular, GraphicsUnit.Point, 0);
but my program is running in wince that don't support "System.Drawing.Text.PrivateFontCollection".
so who know how to implement this through winapi.
|
|
|
|
|
If you use Reflector, you can easily dig out the internals of how PrivateFontCollection works, and wrap up your own implementation using just the bits you need. (Here's a hint - I just took a quick peek using Reflector and found that adding a new font relies on:
[DllImport("gdiplus.dll", CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling=true)]
internal static extern int GdipPrivateAddMemoryFont(HandleRef fontCollection, HandleRef memory, int length);
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Not sure. See if this[^] helps. Looks somewhat similar to what you are doing.
|
|
|
|
|
My program creates a registry key under HKEY_CURRENT_USER\Software.
There is no problem creating the key or creating values underneath it.
However the framework throws an UnauthorizedAccessException when I try to delete the key using the "DeleteSubKey" method of the RegistryKey class.
The program is running as the same user that created the key.
This is on Vista SP2.
What could I be missing? I thought that a user has total access to keys underneath HKEY_CURRENT_USER?
|
|
|
|
|
Never mind!
I found out that I'm supposed to open the key with delete-access to begin with.
Thanks for reading my post.
|
|
|
|
|
hi.
I need help in this.
I have a textbox and two radiobutton.
For example, If the data in the textbox is yes, I want the yes button to be selected. If the data in the textbox is no, the no button is selected.
so far the code i have is this,
if (query returns true)
{
VMradioButton.Checked = true;
TnRradioButton.Checked = false;
}
else{
VMradioButton.Checked = false;
TnRradioButton.Checked = true;
}
please, need help. thanks
|
|
|
|
|
A) Why? Why not just use the RadioButtons?
B) If the RadioButtons are in the same group, you only need to check one, the framework will uncheck the other(s) for you.
Otherwise, I'd use the TextChanged event of the TextBox and maybe a switch .
|
|
|
|
|
thanks for the reply.
what is switch?
sorry, im a newbie.
|
|
|
|
|
google it, or go to msdn.com search keywork switch .
|
|
|
|
|
|
Just put them in the same panel or group box and it will be automated
Natza Mitzi
|
|
|
|
|
|
Hello guys,
I needed to create a proxy by adding a web reference into my C# class library project, but there's been some issues configuring the thrid party product and the webservice they expose....so I have manually downloaded the WSDL file (its not asmx, its actually java/ibm web service).
Anyways, since i can't use the add web reference wizard from Visual studio anymore, I'd like to know how to I create a porxy (Reference.cs) file in my project using the WSDL file located on my C drive.
Can anyone point me to the right direction, I treid looking into Wsdl.exe but looks like it only support a URL and not a local path, if it does can someone point me to the right command syntax?
I'd appreciate your help.
Thanks
Tina
|
|
|
|
|
I use svcutil.exe [^] to manually generate WCF proxies.
/ravi
|
|
|
|
|
Hello Ravi, thanks for the response...but I should have mentioned, I'm using VS 2005 framework 2.0.
Can you tell me how do i do that in this environment?
Thanks
|
|
|
|
|
Run the svcutil.exe command line app located in your VS2005 installation folder hierarchy. See the online docs for the app's command line args. svcutil.exe is what runs when you do Add | Service Reference from the VS200x GUI.
/ravi
|
|
|
|
|
Hi,
I'm trying to figuring out how to add an object (insert a new row), when the object is related to another entity.
Eg.: I have a user entity, each user can have a title ("Mr.", "Ms.", "Dr.", etc.) or no Title assigned at all.
Entity Model
So you see, the user entity is mapped to the the title entity. Navigation properties exist also (directly generated from the wizard).
In the database, the tables look like this:
DB diagram
The user table has a column "title_id" which is the foreign key for the primary key of the table "titles".
My question is now, how do I add a new user object and directly associate it with an existing title.
I tried various ways, but I get different exceptions when attaching the user entity to the Context. Eg.:
{System.InvalidOperationException: The object cannot be added to the ObjectStateManager because it already has an EntityKey.}
or
"An object with the same key already exists in the ObjectStateManager. The existing object is in the Unchanged state. An object can only be added to the ObjectStateManager again if it is in the added state."
My create user method looks like this:
public int CreateUser(User user)
{
this.context.AddToUsers(user);
this.context.SaveChanges();
return user.UserId;
}
... where I've previously assigned the desired "Title"-Entity to the passed User-Entity, eg:
user.Title = dataAccess.GetTitleByTitleId(titleId);
So, I guess the problem is in this part.. as this given Title-Entity modifies the User-Entity in a undesired way. I've also tried to get rid of the "Title"-navigation property and add the "TitleId" property direclty to the "User" entity, so I could simple assigne the desired "TitleId" to the user (user.TitleId = titleId; ), but this gives me various validation errors in the entity model designer.
Does anybody know how to do this (simple task?) in a correct way?
Thanks, Shi
|
|
|
|
|
Am I just crazy or is it kind of hard to find a sample on using WIA with a digital camera.. I also read something that you might not be able to do this with Vista?
I got my camera to take a picture...
Item pic;
ImageFile myImg;
pic = _Device.ExecuteCommand(CommandID.wiaCommandTakePicture);
myImg = (ImageFile)_Device.Items[0].Transfer(FormatID.wiaFormatJPEG);
PictureBox picBox = new PictureBox();
picBox.Dock = DockStyle.Fill;
picBox.Image = (Image)myImg.FileData;
this.Controls.Add(picBox);
But on trying to Transfer I get:
Exception from HRESULT: 0x8021006B
|
|
|
|
|
Sorry I meant I'm getting a NullReferenceException.
|
|
|
|
|
Whatever I do it always returned null!
|
|
|
|
|
I realize this is a little old, but maybe this will help others. My code is in VB but does not take much to convert to C#.
In XP this code takes and saves a picture:
item = dev.ExecuteCommand(CommandID.wiaCommandTakePicture)
Dim myImage As WIA.ImageFile = CType(item.Transfer(format), WIA.ImageFile)
myImage.SaveFile("c:\somewhere\mypicture.jpg")
But in Vista "item" is ALWAYS NULL but it does take the picture on the camera.
here is my fix:
' get current image count
Dim cnt As Int32 = dev.Items.Count
'take picture
item = dev.ExecuteCommand(CommandID.wiaCommandTakePicture)
' insert this single if block
If IsNothing(item) Then
' Vista drops the ball here (and a lot of other places!)
' Loop for up to 10 seconds waiting for the image to appear on camera device
While dev.Items.Count = cnt And x < 10
System.Threading.Thread.Sleep(1000)
x+= 1
End While
If cnt = dev.Items.Count Then
'throw your exception here - no image arrived
Else
' we found the new image on the camera
' pull it into the "item" variable since Vista didnt
item = dev.GetItem(dev.Items(cnt - 1).ItemID)
End If
End If
' and the rest of the code is unchanged.
Hope that helps.
|
|
|
|
|
You know I got it to work with WIA1 but never the version WIA2.
Thats because I used WIA1 on XP and WIA2 on Vista.
I see what you are saying. I was always able to get the camera to take a picture, but it never assigned the picture to the item.
I see what you did. You just take the amount of pictures on the camera, make it snap a picture, then if item is null (which is always will be) loop for 10 seconds OR until the count changes on the camera. Then get the last picture.
Genius! I'll give it a try
|
|
|
|
|
I write new application server/client. I use TcpClient. When my server is listening and allow many computers connect. Example : My server have 50 computers client connected. I have problem when I want to send 1 message to all clients, I must use FOR/NEXT therefore It cost 5 seconds or more to send 1 message to 50 Computers client. Now I want to improve speed of send message, Please give me advice.
Please see code below
//Send Admin Message
public static void sendAdminMessage(string sMessage)
{
//ArrayList LIST_CLIENT contain all connections of client
if (LIST_CLIENT.Count > 0)
{
Object []arr = LIST_CLIENT.ToArray();
for (int i = 0; i < arr.Length; i++)
{
try
{
MyClient client = (MyClient)arr[i];
send(client.TcpClient, sMessage);
}
catch(Exception e) {
Console.WriteLine(e.Message);
}
}
}
}
|
|
|
|