|
A transparent panel?
hmmm pie
|
|
|
|
|
Yep tried that. And I would think that it would work but it puts a black box over my image. I even tried to set the transparencyKey and that just cut a hole through my app. But in idea a transparent panel should work. Any thoughts?
|
|
|
|
|
I tried with a background image and the following worked fine:
this.panel1.BackColor = System.Drawing.Color.Transparent;
this.panel1.Click += new System.EventHandler(this.panel1_Click);
So panel with a background image instead of a pisture box would work fine.
hmmm pie
|
|
|
|
|
ok well my app is a little different. here a small sample of the app.
//this is my overloaded constructor
//gets loaded when the form is first Initialized
public HighCapacity(Skins sk) {
// I put the panel before the InitializeComponent() to get it to load.
// everything will need to be loaded dynamically
InitializeComponent();
//sets the border syle to none to I can add my own
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
//menuOff is a PictureBox that displays as the form
this.menuOff.Image = new Bitmap(sk.DayMenuSkin);
this.menuOff.SizeMode = PictureBoxSizeMode.CenterImage;
this.menuOff.SizeMode = PictureBoxSizeMode.StretchImage;
this.ClientSize = new Size(800, 600);
//set the background of menuOff
if (sk.BackgroundSkinType == "COLOR") {
//this.BackColor = Color.FromArgb();
} else if (sk.BackgroundSkinType == "IMAGE") {
this.menuOff.BackgroundImage = new Bitmap(sk.BackgroundImage);
} else {
this.BackColor = Color.Black; ;
}
this.menuOff.SizeMode = PictureBoxSizeMode.AutoSize;
this.Controls.Add(this.menuOff);
}
|
|
|
|
|
this.menuOff.Controls.Add(this.panel1);
Visual studio is a bit silly when it comes to moving the transparent panel over the image as it resets the above to add it to the form instead which is why it gives a black box.
hmmm pie
modified on Monday, February 23, 2009 6:22 AM
|
|
|
|
|
That did it lol. Thanks allot dude!!!!!
|
|
|
|
|
Hey.
I'm trying to create a client which responds to specific packets. The idea is, i'm going to have a large array of struct "packet" which stores information such as, the type of packet, the length of the sent packet, and a corresponding function it should call.
I know in C++ you can parse functions as parameters quite easily, or with some coding. However, in C# you need to use either delegate functions, or use the Reflection.MethodInfo methods.
The delegate functions may work, but the code to setup each row for my array would be extremely long and rather messy. I tried using the MethodInfo method instead, but the functions i'll be calling are marked with unsafe , and so my byte* parameter can't be passed through as an object in the object[] params :\
Is there any other method I could use to automate this system? Here's a snippet of what I mean:
_packetDB[++i] = new Packet() { type = 0x73, len = 11, func = "authok" };
Where "authok" is a function in a class foo . (When the packet is received, it will search for packet 0x73, and send the byte* data, the length into the function func )
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
You should be using delegates. In general, its best to avoid the use of unsafe code or PInvoke, whenever possible. For your scenario, you should only need to do the following:
unsafe delegate void PacketHandler(byte* data, int length);
struct Packet
{
int type;
int len;
PacketHandler func;
}
void CreatePacket()
{
Packet packet = new Packet
{
type = 0x73,
len = 11,
func = AuthOK
};
}
unsafe void PacketProcessor(Packet packet)
{
byte* data = GetPacketData(packet.type);
packet.func(data, packet.len);
}
unsafe void AuthOK(byte* data, int len)
{
}
|
|
|
|
|
Oh! I always thought you had to define delegation functions as new DelegateFunction(FunctionToCall);
Thanks a lot, you're a life-saver. This should make the system work much, much better
|
|
|
|
|
Glad to be of service.
|
|
|
|
|
I have a list box in my app and i want it to autoscrol downward so it would always show the last item added.
Thank you
|
|
|
|
|
I think you have to do it manually. After adding an item to the end, call EnsureVisible[^].
|
|
|
|
|
didn't quite catch that... can u be more specific with the code?
|
|
|
|
|
Something like this:
int index = listBox.Items.Add("New item");
listBox.EnsureVisible(index);
[EDIT: Wait!! I was thinking of ListView instead of ListBox. Sorry! I'm looking into it right now.]
|
|
|
|
|
Found it!! Use the TopIndex[^] property of the ListBox control.
[EDIT: Oops, Luc beat me to it. ]
|
|
|
|
|
Hi,
whenever you change the number of items, do a myLB.TopIndex=myLB.Items.Count-1;
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:31 AM
|
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
After hours of searching I finally got this far and I'm not getting any errors
from this code. However I'm getting a black image. Is there something amiss here. I need to get access to this image regardless of wether it's visible on the physical montior or not and I'm assuming this may be the best way.
IHTMLElement test = (IHTMLElement)webBrowser1.Document.Images[i].DomElement;
IHTMLElementRender testRender = (IHTMLElementRender)test;
int hScreen = GDI.CreateCompatibleDC(this.CreateGraphics().GetHdc());
testRender.DrawToDC((IntPtr)hScreen);
int hCompDC = GDI.CreateCompatibleDC((IntPtr)hScreen);
int nWidth = webBrowser1.Document.Images[i].ClientRectangle.Width;
int nHeight = webBrowser1.Document.Images[i].ClientRectangle.Height;
int hBmp = GDI.CreateCompatibleBitmap((IntPtr)hScreen, nWidth, nHeight);
int hOld = GDI.SelectObject((IntPtr)hCompDC, (IntPtr)hBmp);
GDI.BitBlt((IntPtr)hCompDC, 0, 0, nWidth, nHeight, (IntPtr)hScreen, 0, 0, GDI.SRCCOPY);
GDI.SelectObject((IntPtr)hCompDC, (IntPtr)hOld);
GDI.DeleteDC((IntPtr)hScreen);
GDI.DeleteDC((IntPtr)hCompDC);
Image img;
pictureBox2.Image = Bitmap.FromHbitmap((IntPtr)hBmp);
|
|
|
|
|
Hi again,
I'm trying to add a little fuction to my app. I have a form for navigating through rows in a database table. All fields (textboxes) are readonly except one, which is a field I want the user to use to go directly to a certain row in the db. All this happens when to user presses the tab button and calls the Validated method of the textbox. How would I go about that exactly? textbox name is txtClientCode , the data in the table is loaded in m_dtClientInfo data table, and data adapter is m_daClientInfo. Database is a MS Access OleDB.
Anyone have a link to a good tutorial on querying and stuff in c#? I checked the articles overhere but didn't find anything! Thanks a lot for your patience with a newb
Yup, I'm a NEWB
|
|
|
|
|
So, when your user tabs out of that specific control, you want to fill the other text boxes with the data at that specific row index? Something like this could do it:
private void txtClientCode_Validated(object sender, EventArgs e)
{
int rowIndex = -1;
if(!int.TryParse(txtClientCode.Text, out rowIndex))
return;
DisplayClientInfo(rowIndex);
}
private void DisplayClientInfo(int rowIndex)
{
DataRow row = m_dtClientInfo.Rows[rowIndex];
txtFirstName.Text = (string)row["FirstName"];
} I hope this helps
|
|
|
|
|
I finally tried it out like this and it works:
private void txtClientCode_Validated(object sender, EventArgs e)
{
try
{
OleDbDataAdapter l_daCCSearch = new OleDbDataAdapter(
"SELECT * from ClientFile WHERE ClientCode = '" + txtClientCode.Text + "'", m_connection);
DataTable l_dtCCSearch = new DataTable();
l_daCCSearch.Fill(l_dtCCSearch);
txtClientCode.Text = l_dtCCSearch.Rows[0]["ClientCode"].ToString();
txtAdress.Text = l_dtCCSearch.Rows[0]["Adress"].ToString();
txtCity.Text = l_dtCCSearch.Rows[0]["City"].ToString();
txtCompanyName.Text = l_dtCCSearch.Rows[0]["CompanyName"].ToString();
txtContactName.Text = l_dtCCSearch.Rows[0]["ContactName"].ToString();
txtCountry.Text = l_dtCCSearch.Rows[0]["Country"].ToString();
txtEmail.Text = l_dtCCSearch.Rows[0]["Email"].ToString();
txtFax.Text = l_dtCCSearch.Rows[0]["FaxNumber"].ToString();
txtPhone.Text = l_dtCCSearch.Rows[0]["PhoneNumber"].ToString();
txtPostalCode.Text = l_dtCCSearch.Rows[0]["PostalCode"].ToString();
txtProvince.Text = l_dtCCSearch.Rows[0]["Province"].ToString();
txtTaxCode.Text = l_dtCCSearch.Rows[0]["TaxCode"].ToString();
rtxtNotes.Text = l_dtCCSearch.Rows[0]["Notes"].ToString();
}
catch (IndexOutOfRangeException)
{
DialogResult result;
result = MessageBox.Show("Aucune entrée correspondante à votre requête n'a été trouvée.", "Erreur");
if (result == DialogResult.OK)
{
this.ShowCurrentRecord();
}
}
}
Thanks a lot you pointed me in the right direction
Yup, I'm a NEWB
|
|
|
|
|
Hi
How can i make pdf from text file or put my text in pdf file ?
(in C#)
thank's for any help
|
|
|
|
|
There probably should be some componentes that allow you to do this easily, but since I don't know about any of them, I'll give you two ideas:
1. Install something like PDFCreator or CutePDF, and then from C# print to one of the PDF pseudo-printers as if you were printing to a regular printer. This will generate a prompt for the filename at runtime (and require an installation on the client), but depending on your particular circumstances it might or might not be acceptable.
2. Use fyiReporting[^], which I just learned about it. It's a reporting control that can output to a variety of formats, including PDF.
Both ideas are free.
You could also try Google[^] and find a lot of results
|
|
|
|
|
HI,
I need to control office excel document in run time.
The problem is that i don't know the office version that install on the target machine ( can be office 2007 or office 2003 ) and I don't know if and how to set the iterope to the office object in run time.
Thanks for the help.
|
|
|
|