|
Hi,
don't use CreateGraphics except for very special circumstances; use the Graphics that is inside PaintEventArgs instead.
chances are the Paint event fires before your game has been fully initialized, so add a null test on game inside the Paint handler.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi
i'm looking for a container control like visual studio toolbox, which on mouse over, it display content controls and on mouse leave, it hide it's content.
can anybody help me ?
Note : i want to add some controls like textBox,comboBox, ... to it, not toolStrip or toolBar controls.
thanks
|
|
|
|
|
Nothing exists, unless it's in a CP article or third party library. Search CP, and then consider if you need to write it yourself.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi Christian
i don't know what's the name of this control to search it.
can u help me ?
|
|
|
|
|
I have no idea either, except that you'd probably search based on behaviour 'Visual Studio toolbox control', for example.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I hope some one out there can help me! I have been goggling my brains out all day tiring to find the answer for this question I have:
I'm using visual studio 2008 and I am pretty much a noob to c#. So go easy on me.
Trying to write a console app that checks the status of a windows service and if it is up stops it and if it's down brings it up! But the problem is that the book I am using to teach myself c# in vs 2008 does not describe this. And also to code that I do find on the web is for 2005 and doesn't work in 2008! I might look a bit liker this:
public static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
But as I stated earlier the ServiceController class doesn't seem to work in 2008, or I could just be a dim whit...
So any idea you might have as of how I might do this would make my day!
Thanks in advice,
Mike
|
|
|
|
|
If you are not getting an exception how do you know the service has not started?
Depending on what OS you are on, the OS properties are reported diffrently.
Take a look at the win32 to .NET API cross refrence.
Microsoft Win32 to Microsoft .NET Framework API Map[^]
|
|
|
|
|
I could be way off here but if you're using Vista (or possibly Weven), IIRC you can only stop and start services if you add a manifest file and elevate to administrator (yeah - that brings in the UAC prompt for your app).
It's a long time since I've tried this so I may be wrong, but I think that this is the case, and also if my memory serves correctly, you don't get any exception - it just doesn't work.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Mike,
It did work for me on VS 2008. Here is my program -
using System;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController service = new ServiceController("<<Your Service Name>>");
service.Stop();
TimeSpan timeout = TimeSpan.FromMilliseconds(10000);
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
if (service.Status == ServiceControllerStatus.Stopped)
{
service.Start();
}
}
catch
{
// ...
}
}
}
}
Are you getting any specific error ?
|
|
|
|
|
First of all I would like to thank every one who has tried to help me thus far, it great! As I said im a noob at c# getting this type of help will bring me to the next level (even if its a still a low one )
I'm am using vista....
when using Shukla's great piece of code I get this:
The problem might be missing a reference?
Error 1 The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\mike\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 2 14 ConsoleApplication1
The problem might be missing a reference?
Also the ebook (Microsoft.Press.Microsoft.Visual.C.Sharp.2008.Step.by.Step)I use to teach myself is not telling me how to link in a external .dll so if you have any good references on this subject I would love to know!
Anyway thank you for you time!
|
|
|
|
|
Hey,
I am programing a program that uses a Web Service to connect between the Server and WinAPP forms.
I made the web service and active my IIS 7 (Using vista ultimate), then i enterd into my localost(using IP) and all go ok (check my defined methods and they returned void XML data)
But when i combine that web service to WinAPP and them bind data to datagrid i got error:
System.Net.WebException: הבקשה נכשלה עם הודעת השגיאה:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fUniversityWebServices%2fService.asmx%3fAspxAutoDetectCookieSupport%3d1">here</a>.</h2>
</body></html>
--.
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
ב- WindowsUniversityClient.UniversityWebReference.Service.GetGradesByStudentId(Int32 id) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Web References\UniversityWebReference\Reference.cs:שורה 83
ב- WindowsUniversityClient.Form1.searchgrades_btn_Click(Object sender, EventArgs e) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Form1.cs:שורה 24 the code i userd
UniversityWebReference.Service service = new WindowsUniversityClient.UniversityWebReference.Service();
try
{
this.grades_dataview.DataSource = service.GetGradesByStudentId(int.Parse(this.studentid_txtbox.Text));
}
catch (FormatException format_e)
{
MessageBox.Show(format_e.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(Exception ee)
{
MessageBox.Show(ee.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Gindi Bar Yahav - Web & Software defeloper.
modified on Saturday, June 20, 2009 10:43 AM
|
|
|
|
|
Hmm, my Hebrew is no so good, but you might try using: int.TryParse() instead of int.Parse(). Also, it is good to use some debug methods for inspecting the SOAP message before and after it is processed. You can do this in debug mode in Visual Studio. Make sure your IO is working correctly. This is the half split, method for finding bugs in SOAP based web services. Then depending on where the problem is manifesting you will know what end point is responsible for the problem.
|
|
|
|
|
Sorry about the hebrew... :$
Isolved the problem
i enterd in the windows form into app.config
and them edit
<setting name="WindowsUniversityClient_UniversityWebReference_Service"
serializeAs="String">
<value>http:
</setting>
To:
<setting name="WindowsUniversityClient_UniversityWebReference_Service"
serializeAs="String">
<value>http:
</setting>
Now, when he hav AspxAutoDectateCoolieSupport it gives me the results
Thanks for your help!, Yahav.
Gindi Bar Yahav - Web & Software developer.
|
|
|
|
|
I need to shut down the entire application when the user clicks this button, but I don't know how to check if the window was closed via the "X" button or some other button.
|
|
|
|
|
Hi,
you should have a look at the Form.FormClosing event, its event arg has a CloseReason property.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Subscribe to the Form.FormClosing event and look at e.CloseReason. If the user closes the Form via Alt-F4 or the 'X' button, then e.CloseReason will be CloseReason.UserClosing. For the rest of the possible values, look in the documentation[^]
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I forgot to mention that I'm actually using a WPF form, and there doesn't seem to be a CloseReason. I posted it here and not in the WPF forums because I thought that this was more of a general issue
|
|
|
|
|
Hi,
I have lot of records in dataset, it is something above "150,000/=".
kindly let me know, is there any quick method to insert these records into new table using MS-Access?
Thank you in advance
(Riaz)
|
|
|
|
|
This [^]might help you
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hello everybody
I have a Form and I use the GDI+ to have a User Interface
I have a Button(just an image) that should be repainted when it is clicked
and I use a flag at the mouse event handler to know when the button is clicked
and in the OnPaint method I check it FIRST, and if the flag was True I don't paint
the BackGroundImage, because it is painted before (at the startup of the Form)
but I don't know why that BackGroundImage is gone when the event occures
and only my button and the BackColor of the Form is shown
=>>note: I don't want to use BackGroundImage because I think it will paint it all the times that the Form is repainted, and it is process intensive
Thank you
P.S: If you want to read this code better you can copy/paste it in VS.NET and
select all the code and use CTRL + (K) then CTRL + (F) to format the code
in a good format to be more readable
here is the OnPaint method:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
if (LanguageTraining)<br />
{<br />
dc.DrawImage(ButtonSelectedBlue, LanguageButtonBounds);<br />
LanguageTraining = false;<br />
base.OnPaint(e);<br />
return;<br />
}<br />
base.OnPaint(e);<br />
Graphics dc = e.Graphics;<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
<br />
<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
dc.DrawImage(piccy, piccyBounds);<br />
dc.DrawString("Language Training", ButtonFont, TextBrush, new Point(755, 625));<br />
<br />
<br />
}<br />
Here is all the code
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace paintImage<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private bool LanguageTraining = false;<br />
private Point MouseClickPosition;<br />
private readonly Brush TextBrush = Brushes.White;<br />
private readonly Font ButtonFont = new Font("alefba", 18,FontStyle.Bold);<br />
<br />
readonly Image piccy;<br />
readonly Image ButtonSelectedBlue;<br />
readonly Image ButtonSelectedGreen;<br />
private readonly Point[] piccyBounds;<br />
private readonly Point[] LanguageButtonBounds;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
piccy = Image.FromFile(@"C:\pics\page1.png");<br />
<br />
ButtonSelectedBlue = Image.FromFile(@"C:\pics\Button Selected Blue.png");<br />
ButtonSelectedGreen = Image.FromFile(@"C:\pics\Button Selected Green.png");<br />
AutoScrollMinSize = piccy.Size;<br />
piccyBounds = new Point[3];<br />
LanguageButtonBounds = new Point[3];<br />
<br />
const int resolutionX = 1024;
const int resolutionY = 768;
<br />
<br />
piccyBounds[0] = new Point(0, 0);<br />
piccyBounds[1] = new Point(resolutionX, 0);<br />
piccyBounds[2] = new Point(0, resolutionY);<br />
<br />
LanguageButtonBounds[0] = new Point(744, 617);<br />
LanguageButtonBounds[1] = new Point(992, 617);<br />
LanguageButtonBounds[2] = new Point(744, 659);<br />
<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
if (LanguageTraining)<br />
{<br />
dc.DrawImage(ButtonSelectedBlue, LanguageButtonBounds);<br />
LanguageTraining = false;<br />
base.OnPaint(e);<br />
return;<br />
}<br />
base.OnPaint(e);<br />
Graphics dc = e.Graphics;<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
<br />
<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
dc.DrawImage(piccy, piccyBounds);<br />
dc.DrawString("Language Training", ButtonFont, TextBrush, new Point(755, 625));<br />
<br />
<br />
}<br />
protected override void OnKeyUp(KeyEventArgs e)<br />
{<br />
base.OnKeyUp(e);<br />
if (e.KeyCode == Keys.Escape)<br />
this.Close();<br />
}<br />
protected override void OnMouseDown(MouseEventArgs e)<br />
{<br />
base.OnMouseDown(e);<br />
MouseClickPosition = new Point(e.X, e.Y); <br />
}<br />
protected override void OnMouseClick(MouseEventArgs e)<br />
{<br />
base.OnMouseClick(e);<br />
if (MouseClickPosition.X > 755 && MouseClickPosition.X < 1024 && MouseClickPosition.Y > 625 && MouseClickPosition.Y < 768)<br />
{<br />
Invalidate();<br />
LanguageTraining = true;
}<br />
}<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
<br />
<br />
modified on Saturday, June 20, 2009 7:56 AM
|
|
|
|
|
Hi,
1.
you can show formatted code by using PRE tags instead of CODE tags
2.
There must be several ways to prevent a background repaint.
for one I would try without the base.OnPaint() statement;
alternatively you can have a look at the ControlStyles Enumeration, and the Control.SetStyle method.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
and thank you for your answer but unfortunately I eliminated the "e.base();"
from the code but the problem wasn't solved
I am trying the other option you mentioned
modified on Saturday, June 20, 2009 8:29 AM
|
|
|
|
|
hi,
i have a Ip address and i want to change it into Variant VT_I4 and then change type to VT_BSTR in .net. Let me know how to do it
|
|
|
|
|
There is no variant in .NET. You could try to use an object instead. I googled for you and couldn't find any better advice.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I am developing an application in which i use to select data from one grid remove that & display it to the second grid.
I store those data in a local mdb file . when i am selecting rows in bulk(around 50-70 at a time)and then wanted to cut and display in the second grid i am getting this error .
Please help.
|
|
|
|