|
I have what is a very annoying and subtle little glitch that I cannot get rid of. I'll try to be brief and to the point.
I have a form, on it are a handful of Label controls that I have subclassed, but I haven't changed the way they draw or render at all, just added some private properties to them specific my app.
When you click on the label, a ContextMenu is shown, and the label's image property recieves a different image to show it in a downstate.
If you chose not to select a menu item and click somewhere within the form, the context menu dissapears, naturally, and the label's image state returns to normal.
However, if you click *outside* the form while the context menu is displayed, say on another application behind the form, which has the effect of the form losing its focus and falling behind, and then if you bring the form back to focus, the label's image can be seen for a half second to still be in its down state before changing back to the normal state.
I have tried to put the code that returns the labels image state to normal *everywhere* in the lifecycle of the form's visibility that I can possibly think of. But no matter what, for a half of a second you can still see it in its down state when the form returns.
I am pulling my hair out. It sounds trivial, but it looks very bad, and I cannot allow it to behave this way when released. Is there something I'm missing? Maybe something to do with validation of controls?
Anything?
Thanks for any ideas people might have and hearing my little tale of woe.
Matttingly
|
|
|
|
|
So adding a Form.Deactivate handler doesn't do the trick? Don't bother with validating stuff, it's just another thing in the focus event sequence. Did you try calling Update() to force an immediate repaint? Otherwise, invalidation just puts a WM_PAINT message in the message queue, which could already be loaded with other pending messages.
|
|
|
|
|
Yeah I tried it in Form.Deactivate and that didn't do anything. It does work, but the point is that it seems to actually get redrawn *after* the form is made visible again.
I should point out when the form is losing focus I make it Visble = False, or I think I might use .Hide().. But when it comes back I tried putting that in the Deactivate() handler and it redraw roughly a half second after the form is made visible again.
I will try Update(), that is one I hadn't thought of. Also I should point out I am using the Opacity property as well as transparency on some parts of the form. I don't see why this would matter, but with that stuff you never know..
Thanks, I'll post back my luck with Update(). I appreciate the response.
Mattingly
|
|
|
|
|
Thanks so much! Update did the trick.. Perfectly
|
|
|
|
|
Can a web service write to the registry on the server hosting it?
I have the following code, it works in a windows forms application, but not in this web service. My try/catch is catching that there is an error, but I am not sure how to display what that error detail is. Second part, and I know this is simple, how do I read in a URL var into my web service? Once I get this working, it's pretty simple, it just needs to read a 4 digit number, then write a string var into the registry on the server hosting the webservice. I am trying to automate some stuff on a windows media server. Here is my code so far:
<code>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using Microsoft.Win32;
namespace wmRegEdit
{
[WebService(Namespace="http://events.activegroup.net/ws/")]
public class wmRegRead : System.Web.Services.WebService
{
[WebMethod]
public string GetRegValues()
{
RegistryKey regKey;
regKey = Registry.LocalMachine.OpenSubKey(@"Software\MyTestRegKey");
string[] valnames = regKey.GetValueNames();
string val0 = (string)regKey.GetValue(valnames[0]);
string val1 = (string)regKey.GetValue(valnames[1]);
return val0 + val1;
}
[WebMethod]
public string WriteRegValues()
{
try
{
RegistryKey regKey;
regKey = Registry.LocalMachine.CreateSubKey(@"Software\MyTestRegKey");
//regKey = Registry.LocalMachine.OpenSubKey(@"Software\MyTestRegKey");
string[] valnames = regKey.GetValueNames();
string val0 = (string)regKey.GetValue(valnames[0]);
string val1 = (string)regKey.GetValue(valnames[1]);
regKey.SetValue("Domain", (string)"WorkGroup");
Registry.LocalMachine.Flush();
return val0 + val1;
}
catch
{
return "reg write error";
}
}
}
}
</code>
Thanks,
Bill K.
|
|
|
|
|
codeweenie wrote:
Can a web service write to the registry on the server hosting it?
Only if it runs under an account with permissions to do so. The default ASP.NET user isn't going to do it. Try the local admin account (if you know the password).
codeweenie wrote:
My try/catch is catching that there is an error, but I am not sure how to display what that error detail is.
Well, you need to rework the catch statement to catch the type of exception you want and then assign it to a variable...like this:
catch(Exception ex)
{
Debug.Writeline(ex.Message);
}
codeweenie wrote:
how do I read in a URL var into my web service? Once I get this working, it's pretty simple, it just needs to read a 4 digit number, then write a string var into the registry on the server hosting the webservice. I am trying to automate some stuff on a windows media server. Here is my code so far:
Why not change your method signature to:
WriteRegValues(int myInput){}
That's the accepted way to do Web Services and is really the whole point. Besides, the ASMX file will show you how to call it via an HTTP request.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
David Stone wrote:
Why not change your method signature to:
WriteRegValues(int myInput){}
That's the accepted way to do Web Services and is really the whole point. Besides, the ASMX file will show you how to call it via an HTTP request.
David,
I really don't understand what you mean with the above text?? Thanks for the heads up on the user account stuff. I was able to get that and the catch stuff working. The catch message told me what I thought it would. And your first point helped me fix that. That just leaves me with needing to get my simple little service to read a value from the url and write it into the reg for me. I think that I am close. I got google fired up and my .Net book too. However if you want to point me along a little farther, I don't mind...
Thanks again,
Bill K.
|
|
|
|
|
Well basically, what I meant was that you should change your method to have an parameter of the type you want to read in. You shouldn't rely on the querystring because what happens when the user calls the WebService from a Windows Forms application? There isn't any querystring. So what I suggest is changing your method from this:
WriteRegValues() {}
to
WriteRegValues(string myInput) {}
Forget the part about the HTTP Request...I was drifting off into another arena all together.
Do you understand how to call a WebService from another application? Are you using VS.NET? Because if you are then you could have an ASP.NET (or Windows Forms) app reference the webservice and then call WriteRegValues("Hey! This'll get written to the registry!");
Hope that clears things up.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
http://localhost/YourFile.asmx/WriteRegValues?myInput=theValueEntered
Would be used to call the WriteRegValues method and to assign a value to it's paramter myInput. I believe this is what you want to know, right? I hope it helps.
"We will thrive in the new environment, leaping across space and time, everywhere and nowhere, like air or radiation, redundant, self-replicating, and always evolving." -unspecified individual
|
|
|
|
|
Hi All
I am using the followinf statment in my app at work
DataRow[] adr = dlg.PMIClient.DataSet.Tables[0].Select("ServerID=" + nServerID.ToString());
the ServerID has long datatype.
this statement works well for the int id values, but if nServerID has a long value and if the value in the dataset the result of select will be nothing even there is a record that has the same id in the dataset
in other words the Select works well if ServerID is int not long.
|
|
|
|
|
In the DataSet definition itself, have you set the ServerID field to int or integer?
If I remember correctly, it must be integer to account for a long value, but whatever it is, try the other one.
Paul
And you run and you run to catch up with the sun, but it's sinking Racing around to come up behind you again The sun is the same in a relative way, but you're older Shorter of breath, one day closer to death - Pink Floyd, Time
|
|
|
|
|
I have a form with a background image. In the form is a user control. I have set the style of the user control to support transparent background. I have also set the color to be transparent. When the user control is drawn in the form, it sometimes show the image in the background fine,but other times, the image in the background is not lined up with the edges of the panel. It looks like the user control is holding on to a different rendition of the form background image that is slightly off centered.
Is there a way to make the image that is showing through the user control be exactly what is in the form background image? I am guessing I have to override the paint method, but the form should not be painting anything in the background, right?
Doesn't the child user control get invalidated when the parent form gets invalidated?
thanks
Bryan
|
|
|
|
|
Hello every one!
I found this article on how to creat a custom IE toolbar (like the one Google has):
http://www.codeproject.com/useritems/toolband.asp
Problem is, that this article is in C++.
Does anyone out there know of an example using C#??
I'd like to write a custom IE toolbar, where the user can download it and install, etc.
Also... the option of uninstalling.
Any help on this will be greatly appreciated!
Thanks in advance!
|
|
|
|
|
C#iruzo wrote:
Does anyone out there know of an example using C#??
There is one called BandObjects(here on CP) that is written in C#
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
|
C#iruzo wrote:
there might be one out there for Internet Explorer...
Its the same thing It works for both. I must warn you that its not very stable. EG, firing a thread do some work and closing the toolbar will cause windows shutdown dialog to be shown...
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
I still haven't seen that behavior, and I'm doing somewhat complex stuff with my vertical Explorer Bar (which is slightly different from an IE toolbar, aka command bar). I'm even using XP.
However, you may find that the Command Prompt Explorer Bar at http://www.codeproject.com/csharp/CommandBar.asp[^] to be extra helpful, as it is an implementation that uses the BandObject library in a somewhat complex way. I think the BandObject library had been revised in the Command Prompt Explorer Bar project, and those changes may not have been updated on the BandObject page.
|
|
|
|
|
Hi, all:
I have WinForm app to edit MS Access DB. On the dataset I have serveral Master-detail tables( the Relation is edited in the schema editorat design time, not runtime). The Master table is databind to a datagrid and detail tables are databind to either datagrids or a set of textbox controls. When I first load ( fill) the data, everything works fine and textboxes display the correct data. When I change selections in the master table, the textboxes change accordingly. Now, when I REOPEN the MDB file, the the tables which databind to the datagrid works as before, but the table that bind to a set of Textboxes do not have any data displayed. I can NOT figure it out what is wrong. I appreciate any help/insight you have. Thanks very much. The following is the code I used to bind the data after I open and fill the dataset: dsMain1
***************
textBox1.DataBindings.Clear();
textBox1.DataBindings.Add(new Binding("Text", dsMain1, "MyMaster.MasterToDetail.name"));
textBox2.DataBindings.Clear();
textBox2.DataBindings.Add(new Binding("Text", dsMain1, "MyMaster.MasterToDetail.Title"));
textBox3.DataBindings.Clear();
textBox3.DataBindings.Add(new Binding("Text", dsMain1, "MyMaster.MasterToDetail.Company"));
***************
Dion
|
|
|
|
|
hello everyone, i'm a new member here ,i'm a student at my last year in computer science facuty & i really need for my graduation project to know if it is possible to send images to clients from a srver in client/server application done using sockets in C#....plz i need all the help i can get..
thank u all...
|
|
|
|
|
Impossible. What you ask is crazy.
Check out System.Net.Sockets
http://samples.gotdotnet.com/quickstart/howto[^]
Look under Networking / TCP Client & Listener.
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
ok ...do u have any other alternative.....plz tell me about it ....plz don't shock me like u did in the first msg...
|
|
|
|
|
Hi
I want to hide my WinForm window (and show a notifyicon).
I know how to do it with the hide and show functions now but at
first i used WindowState = Minimized and ShowInTaskbar = false.
When i then try to show my window again i cant get it to be normal,
minimized and maximized works but not normal?!?
For example if i run this code i cant get my window back...
private void button1_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
this.ShowInTaskbar = true;
this.WindowState = FormWindowState.Normal;
}
TIA Mauritsius
|
|
|
|
|
add this.Visible = True between this.ShowInTaskbar = true; and this.WindowState = FormWindowState.Normal; .
|
|
|
|
|
no, this didn't work .SRod. !!
Why ???
FormWindowState.Normal restores the previous statenot size and when the form is minimized the size is zero
this.ShowInTaskbar=false;<br />
this.Hide();<br />
this.Show();<br />
this.ShowInTaskbar=true;
|
|
|
|
|
when the ShowInTaskbar property value is changed, the underlying control is destroyed and recreated, hence the zero size. To get the right size, I believe you should call this.Handle (in fact, the implementation for this.Handle ensures the underlying control is created before it passes the handle back).
public void Forms.set_ShowInTaskbar(bool value) {
if (this.IsRestrictedWindow)
return;
if (this.ShowInTaskbar != value) {
if (value)
this.formState.set_Item(Form.FormStateTaskBar, 1);
else
this.formState.set_Item(Form.FormStateTaskBar, 0);
if (this.IsHandleCreated)
this.RecreateHandle();
}
}
|
|
|
|