|
IIRC, no there isn't. The insertion point can't be hidden on a control that can receive keystrokes.
I could be wrong though...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
<br />
[DllImport("user32.dll")]<br />
static extern bool HideCaret(IntPtr hWnd);<br />
Hides the caret temporarily.
Remember to include:
using System.Runtime.InteropServices;
Example:
<br />
HideCaret(richTextBox1.Handle);<br />
Hope this helps
|
|
|
|
|
Ahhh! I thought there might be something I was forgetting!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I would like to make the images concaternated and display it.
For example, I would like to put COUP images together and display them together. I can display the first image but am not able to display the second images.
How can I concaternate two images and display them together in c#?
Here is my tables:
Data table
Transactionid documenttype frontimage offset frontimage size
1934318415 CHECK 1 11264
1934318415 COUP 18433 27648
1934318415 COUP 57345 39936
The front/rear offset tell you where the image data in image table begins and the front/rear length tell you how many bytes from the offset to extract to get the image out of the Image table..
Image table
Transaction ID, Image
1934318415 <binary>
Here is the code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Data.SqlClient;
using System.IO;
using System.Drawing.Imaging;
using System.Collections.Generic;
public partial class GetImage : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_GetMultipleImages();
}
public void _GetMultipleImages ()
{
string TransactionId;
string sql;
byte[] imageBytes = null;
TransactionId = (string)this.Request.QueryString["TransactionId"];
if (TransactionId == null) return;
TransactionId = int.Parse(TransactionId).ToString();
sql = "Select Image from Image where TransactionId=" + TransactionId;
ConnectionStringSettings cnSetting =
ConfigurationManager.ConnectionStrings["AppConnectionString6"];
using (SqlConnection cn = new SqlConnection(cnSetting.ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(sql, cn))
{
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
dr.Read();
imageBytes = (byte[])dr["Image"];
}
}
}
}
if (imageBytes == null || imageBytes.Length == 0) return;
List<byte> imgBytes = new List<byte>();
using (SqlConnection cn = new SqlConnection(cnSetting.ConnectionString))
{
sql= "select FrontImageOffset, FrontImageSize,Rearimageoffset, RearImageSize from Image a join Data b on a.transactionid = b.transactionid where documenttype = 'CHECK' and b.TransactionId=" + TransactionId;
using (SqlCommand cmd = new SqlCommand(sql, cn))
{
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
if (dr.Read())
{
long imagebytesLen = imageBytes.Length;
MemoryStream ImageStream = new MemoryStream(imageBytes);
do
{
int frontoffset = Convert.ToInt32(dr["FrontImageOffset"]) - 1;
int frontlength = Convert.ToInt32(dr["FrontImageSize"]);
int rearlength = Convert.ToInt32(dr["RearImageSize"]);
if (imagebytesLen >= (frontlength + rearlength))
{
byte[] newimage = new byte[frontlength + rearlength];
ImageStream.Seek(frontoffset, SeekOrigin.Begin);
ImageStream.Read(newimage, 0, newimage.Length);
imgBytes.AddRange(newimage);
}
} while (dr.NextResult());
ImageStream.Close();
}
}
dr.Close();
}
}
}
if (imgBytes.Count > 0)
{
Bitmap bmp = new Bitmap(new MemoryStream(imgBytes.ToArray()));
Response.ContentType = "Image/gif";
bmp.Save(Response.OutputStream, ImageFormat.Gif);
Response.End();
}
}
}
|
|
|
|
|
I want to create a multiplayer boardgame which allows players to either connect to a central server and join a game, or to host their own game and have their computer act as a private server. Security is also a high priorty for me, since I plan on creating a points system which leads to prizes, etc, so I don't want anyone to be able to cheat. So my question is: is C# the right language for this?
I've done most of my programming in C++ and Java in the past. Most of my applications have been computational or console apps, so I've never really gotten into GUI design (though I've done some basic swing and a little mfc). Likewise, I've never done anything at all with regards to network programming and setting up client/server applications.
I'm new to C# (all I know right now is from the FAQ on this forum), and it seems like what I want to use, but I'm not sure. Would you recommend it over say C++ and/or Java?
|
|
|
|
|
Dear .Net provide a hell lot easire classes for network programming and the graphics related work u want to do + you cant use Crypto Classes to encrypt ur messages to send and receive from the peers.
Dotn worry. Just Go Ahead.
Cheers,
Best Regards,
Rizwan
|
|
|
|
|
dotnetdev83 wrote: Dear .Net provide a hell lot easire classes for network programming and the graphics related work u want to do + you cant use Crypto Classes to encrypt ur messages to send and receive from the peers.
Yes, .NET provides fairly easy networking and graphics classes. But, easier than what?
What do you mean "you can't use crypto classes"? Why not? I don't have a problem with the crypto classes, unless going to or from the Compact .NET Framework because it has only a subset, so you have to work with the crypto classes available in the Compact .NET Framework if you are going to use that. Otherwise it has a good selection of classes that you can use to block encrypt or encrypt a stream.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Sorry Boss It was a typing mistake . I wanted to write you CAN use Crypto Classes. Sorry Again.
Best Regards,
|
|
|
|
|
C#/java would be faster and easier to do the implementation in, but from a security perspective both have the same weakness. The distributed programs are compiled to an intermediate format rather than machine language which is much easier to reverse engineer. IF your design is poor that could result in an easier attack path for cheaters. Provided you validate *everything* on the server (all user input is bad until proven otherwise), and don't send the user any data they can't currently see (out of sight areas of the map, private details of opponents) this shouldn't be a major issue. You should do both of these even if you're using c++, if the prizes are good enough the same cheating can be done by packet sniffing and writing a custom cheat client.
C# is my langauge of choice, but it's always a good thing to know the limitations before you begin.
|
|
|
|
|
Thanks for the advice all, I think I'm going to go ahead and write it in C#.
|
|
|
|
|
Hello Gurus I'm facing a problem that is pissing me off for hours. I have a simple serializeable class named Message1. Here is the code for it.
[Serializable]<br> public class Message1<br> {<br> private string chatMessage;<br> private bool isPrivate;<br> private string sender;<br><br> public string ChatMessage<br> {<br> get<br> {<br> return chatMessage;<br> }<br> set<br> {<br> chatMessage = value;<br> }<br> }<br><br> public bool IsPrivate<br> {<br> get<br> {<br> return isPrivate;<br> }<br> set<br> {<br> isPrivate = value;<br> }<br> }<br><br> public string Sender<br> {<br> get<br> {<br> return sender;<br> }<br> set<br> {<br> sender = value;<br> }<br> }<br> <br> public Message1()<br> {<br> } And 1 TcpListener and 1 TcpClient. I want to encrypt the message field of Message1 Class and relay it on the network after serializing an object of Message1 using BinaryFormatter. It encrypts fine and serialization is also 100% ok. When i receive it on the server end and deserialize it and decrypt the message field. it gives me some wrong string. Code for Server:
<br>listener = new TcpListener(IPAddress.Any, 9000);<br> listener.Start();<br> client = listener.AcceptTcpClient();<br> dataStream = client.GetStream();<br> msg = new Message1();<br> formatter = new BinaryFormatter();<br> msg = (Message1)formatter.Deserialize(dataStream);<br> string str = Chiper.Decrypt(msg.ChatMessage);<br> MessageBox.Show("Message : " + str + " Private : " + msg.IsPrivate.ToString() + " Sender : " + msg.Sender);<br> listener.Stop();<br>
Code for the Client:
<br> msg = new Message1();<br> msg.Sender = "Rizwan Ahmed";<br> msg.ChatMessage = Chiper.Encrypt("Hello how are you?");<br> msg.IsPrivate = true;<br> client = new TcpClient();<br> client.Connect(IPAddress.Parse("192.168.0.28"), 9000);<br> formatter = new BinaryFormatter();<br> formatter.Serialize(client.GetStream(), msg);<br> System.Threading.Thread.Sleep(1000);<br> client.Close();<br>
Output: msg.ChatMessage : SGVsbG8gaG93IGFyZSB5b3U/AAAAAAAAAAAAAAAAAAA= Please help me solving this matter I'll be really thankful to you. THanks alot in advance.
All is well without encryption or decryptionbr>Hint:Encrypted sting on the receiving end is same as the client sends after encryption but when i decrypt on the receiving end "Hello how are you?" becomes "SGVsbG8gaG93IGFyZSB5b3U/AAAAAAAAAAAAAAAAAAA=". What goes wrong on the network Please Help me. God bless you.
Rizwan
-- modified at 15:33 Friday 13th January, 2006
|
|
|
|
|
What exactly is Chiper? Custom class? Are your sure it is doing the right thing?
You should check it with something like this:
string msg = "Hello world!";
if (!msg.Equals(Chiper.Decrypt(Chiper.Encrypt(msg))))
MessageBox.Show("Chiper is not working correctly.");
Encrypt and Decrypt also seem to be static. Is there any password or something like this which is probably different on client and server side?
|
|
|
|
|
Sir Thanks alot for your interest.
I have figured out the solution. Yes Chiper is my own class all is working well. I just mistakenly converted the decrypted bytes into Base64 string as i do after Chiper.Encrypt() replacing return Convert.ToBase64String() to return Encoding.ASCII.GetString() in Chiper.Decrypt() method. It's working fine now thanks alot again.
Yeh that'sll be my help if you tell me whats the difference between Base64 string and the string one we get from Encoding.ASCII.GetString()??? and why it is needed in in the Encryption classes? Why Encoding.ASCII looses the information?? Thanks alot again Sir.
Best Regards,
Rizwan Ahmed
|
|
|
|
|
base64 is a binary encoding scheme for email attachments. The email protocalls are ancient and were written so long ago that the performance gained by using 7 bit bytes instead of 8bit bytes. Base 64 takes a series (7bytes?) of 8bit bytes and encodes them as series of 7 bit bytes (8bytes?) which are represented in modern hardware as 8 bit bytes with the high bit set to zero. It might also contain parity or ECC bits, I'm not overly familiar with it.
|
|
|
|
|
Helo.
I have to do a custom control which represents the wireless connections of a device. It looks like a listview, but it must be custom (it must look in a certain way, and its elements are pretty complicated). I also must implement a vertical scroll, in case the connections don't fit the window.
Anyway, I am not really sure of how to implement these things. How do I make the (custom) listview scrollable? I can't use the standard scrollbar because it also must match the look of the application.
Thanks
|
|
|
|
|
i posted a question about customize a scrollbar, and i get the advice to create one by alone!
Use 3 panels 1 for the up button, one for the scroller and one for the down button.
then place your own graphic inside.
Just a bit of code and you get your custom scrollbar.
If you have problem, just ask!
|
|
|
|
|
yeah, I thought of that, but how do I implement the custom listview such that only a portion of it is to appear on the screen? If I can do this well, the scroll bar thing will be pretty easy.
|
|
|
|
|
Being new to C# I have always wondered, how do people know the following:
Classes and there methods and what method is doing what?
For eg:
DataGridTextBoxColum > to achieve custom looks override the Paint method!
How do they know to do that? Is there a manual out there that I don't know about?
Or another good one:
//To invoke the method used when user double click on column to resize!
MethodInfo m = t.GetMethod("ColAutoResize", BindingFlags.Instance | BindingFlags.NonPublic);
How do you know that? Who tells a person to go and get the information from? I would love to know all that can some one here solve this mystry please??? thakns
|
|
|
|
|
Take this documentation + some experience + google and you're done
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
There is no manual that explains all this stuff. It's just put together from A LOT of experience and research. A lot of the code you see is dictated by how Windows works, which is documented here[^]. When the Windows API was written, it was done with C++ in mind, not the .NET Framework. So all the code and examples in the Platform SDK will be written in C++. You have to translate the code into whatever language you're using.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: So all the code and examples in the Platform SDK will be written in C++
Huh? If you need C# documentation MSDN has everything you need.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I think you mis-understood what I was talking about. The C# documentation DOESN'T cover the Windows internals like the Platform SDK does.
It covers stuff like, "to do this, write that". It doesn't cover why it works the way it does. For example, overriding WndProc. You can easily capture any and all window messages headed for your app and react to them, but the C# documentation doesn't go into what a window message is or how windows actually work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Taurian110 wrote: How do they know to do that? Is there a manual out there that I don't know about?
My main source of information is reading articles, books[^], magazines (like MSDN Magazine[^], Software Development Magazine[^]), attending/organising user groups (Scottish Developers[^], Agile Scotland[^], eXtreme Wednesdays[^]), listening to DotNetRocks[^], and IT Conversations[^]
I hope I've not left anything out.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Another good resource are Reflector-like tools. If you don't understand what a special class does than you can just look into the code.
|
|
|
|