|
Or
if (dest is System.Windows.Forms.TabControl) ...
<a TITLE="See my user info" href=http:
|
|
|
|
|
Hi all,
I was looking for ID for the button on the form and tried to use GetDlgCtrlID( hwnd) but instead of button ID I got the same handler that I passed to this function - handler to button window
private void test_Click(object sender, System.EventArgs e)
{
int i = GetDlgCtrlID(button1.Handle);
}
[DllImport("User32.dll")]
public static extern int GetDlgCtrlID(IntPtr hwndCtl );
When I did the sane in VB 6.0 this API worked properly.
In VB.NET same behavior as in C#
Does anyone faced such a problem ?
Is there may be another way how to get control ID that exist on the form
Thank you very much in advance
Roman
|
|
|
|
|
Hi im new to this message board, so hello to everyone.
Here's the gist of my problem.
Im creating a bascily program, that allows me to drag and drop boxes onto a canvas area.
I have all the code for drawin the boxes, and moving the boxes.
All the boxes are stored in an arraylist, along with there positions.
The problem is, that when i have selected a box, and i am draging it, I have to clear the canvas in white, redraw all the other boxes, and redraw the selected box. This creates a very noticible flicker around all of the other boxes, as they are being cleared and redrawn after every move of the mouse.
Does anybody have any sudgestions on how i can remove this flicker?
Thanks Anand
|
|
|
|
|
you need to use "double buffering", this tcehnique relies on drawing onto a hidden area and transfer the finished image in one move. Also look at validate rectangle - you only need to redraw the parts of the image that are invalid.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
this.SetStyle(ControlStyles.DoubleBuffer,true);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
You should also specify AllPaintingInWmPaint and UserPaint.
The first makes it so that the PaintBackground event is called from within the Paint event instead of the windows WM_ERASEBKGND message. If you don't specify this then the PaintBackground event is fired outside of the double buffer which can have some side effects (like flicker).
The second tells the framework to use your OnPaint/Paint handler instead of letting windows do the painting.
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint,<br />
true);
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Hello,
I am an utter newbie with C# and DirectX. None the less, I'm determined to learn C# using Managed DirectX. I'm developing a stupid game to increase my nearly non-existant knowledge and I've hit a snag. Okay, two snags.
I create a surface for a plane image, my background, back, and front. Since this is a windowed program, I can't just use normal coordinates for drawing and have to create a rectangle at the window's location (the picturebox I'm drawing to). So I create a rectangle for my plane and background and draw them to the back surface then finally to the front surface which is displayed.
This works pretty well, except, when I move the window part-way off my monitor's screen, I get an Invalid Rectangle exception. I figure when my rectangles I'm drawing to extend off screen it throws that exception. Unfortunately, I have no idea what to do about it. I can catch the exception, but then what do I do with it? Surely windowed games don't all throw Invalid Rectangle exceptions when they're moved off the screen. There has to be something I'm doing wrong.
My next problem is totally baffling to me. I decided I wanted to use System.Drawing.Bitmap's along side with DirectX since DirectX's Surface class supports that object. In my non-DirectX program I can simply load the image with myBitmap = Bitmap(GetType(), "bitmap.png"). No worries. But in my DirectX program, using the EXACT same settings, files, and resources it says it can't find "bitmap.png" resource in that class. This is driving me up the wall. The resouce is there! It works in my other program! There is -nothing- different. In my DirectX program I have to load the file with a different constructor: myBitmap = Bitmap("c:\bitmap.png") works. But... why?! Why won't it work the other way?
Anyone out there that can help me?
Especially evil today,
EvilDingo
|
|
|
|
|
Having only a little knowledge of DirectX I can only offer somethings I remember from long ago. In unmanaged DX there was a Clipper object that you had to attach to your window to ensure you didn't draw off the window (I assume the screen as well). Maybe that will help.
Now the real reason I replied:
EvilDingo wrote:
in my DirectX program, using the EXACT same settings, files, and resources it says it can't find "bitmap.png" resource in that class.
Refer to my Embedded Resources[^] article for more indepth information but I have a couple ideas off-hand.
1) Make sure you set the Build Action on your .png to 'Embedded Resource'.
2) Rather than using GetType , use typeof(MyType) . When you later decide to derive a class from that one (maybe in another assembly or a different namespace) you'll eliminate any problems arising from GetType now returning a different Type object.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
James,
I really appreciate you repling to me because you tipped me off to my Rectangle Exception. There was no clipper associated with the back surface and that is what ended up causing all the trouble. I had been working on this problem longer than any programming problem I've had in many moons. I guess that's to be expected when learning a new language...
I read your excellent resource article and I have one question. When using embedded resources, does that actually include the image file in the executable? Or does there still need to be an external file distributed?
Since I just worked out the drawing problem, I haven't tried loading a resource yet, but to answer your question, I did have it marked as an Embedded Resource in VS.net. Is there any benefit to using it as an embedded resource as opposed to just loading the image file with the filename string constructor?
Thanks,
EvilDingo
|
|
|
|
|
EvilDingo wrote:
using embedded resources, does that actually include the image file in the executable?
Yes, the file will be embedded in the assembly. You still need to keep the file around for building purposes, but you don't need it in order to run the application once built.
EvilDingo wrote:
Is there any benefit to using it as an embedded resource as opposed to just loading the image file with the filename string constructor?
You don't have the extra file lying around so the user can't modify or delete it Aside from that I can't think of any technical reason for using an embedded resource, but usually not having the extra file lying around is enough for me to make it one.
Sorry if some of this in incoherent, I was just on my way to get some sleep
|
|
|
|
|
The CP Anonymous bug bites again
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Does it matter how large the .exe file gets? I used to program in DOS and the eventual .exe size was a big consideration. If it doesn't matter with Windows and .NET then embedding them is the way to go. For ease of use.
EvilDingo
|
|
|
|
|
Can somebody explain me, how i can copy the content from a ListView row into a database or into an array.
Many thanks
Kind Regards
|
|
|
|
|
Hi There,
I hope somebody can give me some good advices:
I need to use an existing Programming Interface which is available whether as a 'COM object dll' or' 2 C++ header files' under .NET.
I used the COM object, this works quite nice in VB.NET and as well in C#, using the System.Runtime.InteropServices.TypeLibConverter class.
In fact everything will be done automatically and i can use my Interface like in the unmanaged world, great!
The main problem is, I develop an application on a PocketPC, under the .NET Compact Framwork.
Since this System.Runtime.InteropServices.TypeLibConverter class does not exist under the .NET CF, i need to use the C++ interface, but this gives me headache.
So far I found out the following:
1)use (unmanaged) C++ Code in the managed world of .NET
2)use the built-in .NET runtime interop facilities to talk directly to the existing code.
3)wrap the code using the managed extensions to C++.
4)rewrite the code in a .NET language.
I wanted to go in direction 4) originally, but I'm no longer sure what makes really sense on this one...
My interface is consisting of 3 header files. 2 of them are simply describing enumerations and structs.
The third one consists of helper classes in C++ which are easing the use of this interface a lot.
I assume that when I would go the wrapping way, that I would only need to wrap the classes I directly touch from my App in c#?
If yes then I woud need to wrap only 2 classes?
What way to go would be the best, wrapping interop, rewrite?
But how would I do that best? Could somebody give me an idea how to do that?
Thanks a lot,
stonee
Attached the sample classes:
<br />
<br />
Class1 to wrap:<br />
<br />
#define DATA_PACKET &Data.DataPacket, sizeof(Data.DataPacket)<br />
<br />
class Command<br />
<br />
{<br />
<br />
public:<br />
<br />
CESAPICommand() {TRACE(_T("CESAPICommand()\n"));}<br />
<br />
<br />
virtual bool SendPacket(void* PacketStart, long PacketSize) <br />
<br />
{ <br />
<br />
TRACE(_T("Virtual SendPacket() called!\n"));<br />
<br />
<br />
return false; <br />
<br />
};<br />
<br />
<br />
<br />
bool inline Init() {CInit Data; return SendPacket(DATA_PACKET);}<br />
<br />
<br />
<br />
<br />
bool inline SetBox(double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2)<br />
<br />
{CSetBox Data(dX1, dY1, dZ1, dX2, dY2, dZ2); return SendPacket(DATA_PACKET);}<br />
<br />
<br />
};<br />
<br />
<br />
<br />
Class2 to wrap:<br />
<br />
<br />
class Receive<br />
<br />
{<br />
<br />
public:<br />
<br />
Receive() {TRACE(_T("Receive()\n"));}<br />
<br />
protected:<br />
<br />
<br />
<br />
bool ReceiveData(void* packetStart, long packetSize) <br />
<br />
{ <br />
<br />
<br />
if (packetStart && packetSize > 0)<br />
<br />
return ProcessData(packetStart, packetSize); <br />
<br />
else<br />
<br />
return false;<br />
<br />
};<br />
<br />
protected:<br />
<br />
virtual void OnInitializeAnswer() {TRACE(_T("virtual OnInitializeAnswer() call\n"));}<br />
<br />
virtual void OnGetBoxAnswer(const BoxRegionDataT& boxRegionData) {TRACE(_T("virtual OnGetBoxRegionParamsAnswer() call\n"));}<br />
<br />
<br />
<br />
protected:<br />
<br />
<br />
<br />
<br />
<br />
virtual bool ProcessData(void *pDataArrived, long lBytes)<br />
<br />
{<br />
<br />
<br />
<br />
PacketHeaderT *pData = (PacketHeaderT*)pDataArrived;<br />
<br />
<br />
if (pData->lPacketSize != lBytes)<br />
<br />
{<br />
<br />
TRACE2("PacketSize (%ld) differs from TotalBytes (%ld) !\n", pData->lPacketSize, lBytes);<br />
<br />
return false;
<br />
}
<br />
switch (pData->type)<br />
<br />
{<br />
<br />
case ES_DT_Command:
<br />
{<br />
<br />
<br />
<br />
<br />
<br />
OnCommandAnswer(*(BasicCommandRT *)pData);
<br />
<br />
BasicCommandRT *pData2 = (BasicCommandRT *)pData;<br />
<br />
<br />
if (pData2->status != ES_RS_AllOK)<br />
<br />
return true;
<br />
<br />
<br />
switch (pData2->command)<br />
<br />
{<br />
<br />
case ES_C_ExitApplication:<br />
<br />
OnExitApplicationAnswer();<br />
<br />
break;<br />
<br />
<br />
case ES_C_GetSystemStatus:<br />
<br />
OnGetSystemStatusAnswer(((GetSystemStatusRT*)pDataArrived)->lastResultStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->trackerProcessorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->laserStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->admStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->esVersionNumber,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->weatherMonitorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lFlagsValue,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lTrackerSerialNumber);<br />
<br />
break;<br />
<br />
<br />
<br />
<br />
<br />
case Init<br />
<br />
OnInitializeAnswer();<br />
<br />
break;<br />
<br />
<br />
<br />
case ES_C_GetReflectors:<br />
<br />
OnGetReflectorsAnswer(((GetReflectorsRT*)pDataArrived)->iTotalReflectors,<br />
<br />
((GetReflectorsRT*)pDataArrived)->iInternalReflectorId,<br />
<br />
((GetReflectorsRT*)pDataArrived)->targetType,<br />
<br />
((GetReflectorsRT*)pDataArrived)->dSurfaceOffset,<br />
<br />
((GetReflectorsRT*)pDataArrived)->cReflectorName);<br />
<br />
break;<br />
<br />
<br />
<br />
TRACE(_T("Unexpected data received (ignored)\n"));<br />
<br />
break;<br />
<br />
}
<br />
return true;<br />
<br />
}
<br />
};
|
|
|
|
|
Hi,
I have been trying to save images as gifs, but I am dissatisfied with the results. The colors are reduced drastically, even if I have specified a highquality pixelformat. I tried changing all kinds of variables such as CompositingMode, SmoothingMode, InterpolationMode, COmpositingQuality etc. Nothing works. However, when I save the image as a jpg, then the color reduction is not as drastic.
I am starting to suspect that the color reduction occurs when the bitmap is saved, in which case the problem most likely has to do with the Gif compression and any settings you can pass to the codec.
Does anyone know how you specify the gif compression when using the Save Method? Where can I read about the compression alternatives? I have already managed to see all my codecs and their properties, but it is of no use to me.
<br />
<%@ Import Namespace="System" %><br />
<%@ Import Namespace="System.IO" %><br />
<%@ Import Namespace="System.Collections" %><br />
<%@ Import Namespace="System.ComponentModel" %><br />
<%@ Import Namespace="System.Data" %><br />
<%@ Import Namespace="System.Drawing" %><br />
<%@ Import Namespace="System.Drawing.Drawing2D" %><br />
<%@ Import Namespace="System.Drawing.Imaging" %><br />
<%@ Import Namespace="System.Drawing.Text" %><br />
<script language="C#" runat="server"><br />
<br />
static PrivateFontCollection pf; <br />
<br />
static void InitPF(string path) <br />
{<br />
pf = new PrivateFontCollection();<br />
string[] ttfs = Directory.GetFiles(path, "*.ttf");<br />
<br />
for (int i = 0; i<ttfs.Length; i++){<br />
pf.AddFontFile(ttfs[i]);<br />
}<br />
}<br />
<br />
public static FontFamily[] GetFonts(string path)<br />
{<br />
if (pf == null) InitPF(path);<br />
return (FontFamily[]) pf.Families.Clone();<br />
}<br />
<br />
void Page_Load(Object sender, EventArgs e)<br />
{<br />
<br />
FontFamily[] pf = GetFonts(Server.MapPath(""));<br />
<br />
<br />
<br />
const int width = 300, height = 41;<br />
Bitmap objBitmap = new Bitmap(width, height, PixelFormat.Format64bppArgb);<br />
Graphics objGraphics = Graphics.FromImage(objBitmap);<br />
<br />
<br />
<br />
<br />
<br />
objGraphics.FillRectangle(new SolidBrush( Color.White ), 0, 0, width, height);<br />
<br />
Bitmap objTile = new Bitmap(Server.MapPath(Request.ApplicationPath) + "\\uploads\\title_tile.gif");<br />
objGraphics.DrawImage(objTile, 0, 0, objTile.Width, objTile.Height);<br />
<br />
<br />
String adPitch = "gif compression";<br />
<br />
int count = 0;<br />
string familyNameAndStyle;<br />
<br />
count = pf.Length;<br />
<br />
<br />
StringFormat stringFormat = new StringFormat();<br />
<br />
if(pf[count - 1].IsStyleAvailable(FontStyle.Regular))<br />
{<br />
myLabel.Text = objBitmap.PixelFormat + "<br>";<br />
myLabel.Text += pf.ToString() + "<br>";<br />
myLabel.Text += pf[count - 1].Name + "<br>";<br />
myLabel.Text += pf.Length + "<br>";<br />
<br />
<br />
Font regFont = new Font(<br />
pf[count - 1],<br />
16);<br />
<br />
<br />
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;<br />
objGraphics.DrawString(adPitch, regFont, new SolidBrush(Color.FromArgb(255, 0, 51, 102)), <br />
new Rectangle(24, 0, width, height), stringFormat);<br />
regFont.Dispose();<br />
}<br />
else{<br />
myLabel.Text = "Not found"<br />
}<br />
<br />
<br />
objBitmap.Save(Server.MapPath(Request.ApplicationPath) + "\\uploads\\banner.gif", ImageFormat.GIf);<br />
objGraphics.Dispose();<br />
objBitmap.Dispose();<br />
}<br />
<br />
</script><br />
<br />
<br />
<asp:label id="myLabel" runat="server" /><br />
Regards,
Christian Toivola
|
|
|
|
|
|
Is there a way to force the display of a notifyicon tooltip? I want the tooltip to be displayed without the user actually hovering over the taskbar icon.
|
|
|
|
|
Check this link out.
Though it deals with the problem in C++ and MFC, just check if it is of some help.
http://msdn.microsoft.com/msdnmag/issues/02/11/cqa/
|
|
|
|
|
Hi,
I have a rather strange problem with RichTextBox controls.
My form has 2 RichTextBox controls and a TreeView. During the runtime, I'll be writing data to both the RichTextBox controls for every 100 m.sec. During this process after some time, which is not always the same, I get the following exception :
System.NullReferenceException: Object reference not set to an instance of an object. at.....
Moreover, even when I right click on the control for popup menu also, it gives the exception. I want to scroll to the end of the control so that the recently added text is visbile. So, I do this in the Text_Changed event :
this.rtxtSECS2Log.Focus();
this.rtxtSECS1Log.ScrollToCaret();
I get the exception even if I comment the above lines and run.
Can any one pull me out of this.
Regards.
Srinivas.
|
|
|
|
|
1. How to create a object in specific server in c#
Eg – in vb createobject(“name”,”server”)
2. Is there any technology in .Net to replace com+
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Gaurika Wijeratne wrote:
Is there any technology in .Net to replace com+
Check out the System.EnterpriseServices namespace
Gaurika Wijeratne wrote:
1. How to create a object in specific server in c#
Eg – in vb createobject(“name”,”server”)
Check out System.Remoting, it can be compared with that of DCOM.
Cheers,
Kannan
|
|
|
|
|
I am already using System.EnterpriseServices namespace
I have also registered the assembly in com+
I just want to create a object in the com+ server, from another machine..
Thanks
Gauirka.
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
ok, i need some help in this matter, and i cant seem to find a solution online
heres the scenario
i created a usercontrol
now, i added in a label and a picture box into it (docked both left)
so now the usercontrol is effectively hidden from the view
so, from the form that i add this control into, i want to create a Click event, referring to when the user clicks the control. i cant get it to work as the usercontrol.click event never fires due to the fact that i cant click directly on the usercontrol (its clicking on either the label or picture box)
now, im gonna use this user control in a lot of forms, and i dont want my only solution to be duplicating the code
uc.label1.click += new eventhandler(clicked);
uc.picturebox1.click += new eventhandler(clicked);
is there any way for me to merge the 2 events into 1?
something like declaring a public event inside the user control then linking it to both controls?
or is there an event type that allows me to specify if any of the child controls are clicked, a certain event will happen
bear in mind that i cannot put the event handler code inside the user control itself, it has to be in the form that calls it
appreciate any help you guys can give me on this matter
|
|
|
|
|
mtrx wrote:
bear in mind that i cannot put the event handler code inside the user control itself, it has to be in the form that calls it
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.
|
|
|
|
|
i mean this
if i have a label inside the user control, i dont want the event handler to be inside the user control also.
i need it to be something like this
class form1
{
public form1()
{
UserControl1 uc = new UserControl1();
uc.Click += new EventHandler(OnClick); // clicking the usercontrol
}
private void OnClick(object sender, EventArgs e)
{
// do event stuff
}
}
i dont want the user control to have the event handler
class UserControl1
{
public UserControl1
{
label1.click += new EventHandler(OnClick);
}
private void OnClick(object sender, EventArgs e)
{
// do event stuff
}
}
my reasoning is because i have several items inside the usercontrol, and im gonna use this user control in a lot of forms, i dont want to be doing several event handlers for each item in the control everytime i want to use it
|
|
|
|
|