|
|
Hi every body,
I want to generate a random number between 0 and 30,000. How this can be done in C#.
In C, it is like this.
int Random = rand()%30,000;
Could any one please help in this regard.
thanks a lot.
|
|
|
|
|
|
Random random = new Random();
int randomNumber=random.Next(30000);
/\ |_ E X E GG
|
|
|
|
|
Hi...
I have a richtextbox, it has about 200 lines, and i want to go to line 125 when i press a button!
I have made this code...
int count = 0;
int GoTo = 125;
for(int i = 0; i < GoTo; i++)
{
count += richTextBoxText.Lines[i].Length;
}
richTextBoxText.Select(count,0);
but this does not work.
My idea was to get all chars from the lines until it reached 125, and then go to the line using the select method.
Can anyone help me how to do go to a line in a richTextBox?
Thanks
QzRz
|
|
|
|
|
RichTextBox.Lines won't return the number of lines in the box that are due to word wrapping, but rather, it will return the number of lines due to new line breaks (Environment.NewLine) in the text.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
I am with a problem in a program to which I am elaborating and I wait that they help me.
In the program a button will be pressured, it must send the information to the other program that keyboard key ENTER was pressured.
In this another program keyboard key ENTER has a definitive function.
This is the logic, however my only one doubts this in:
As to determine that the keyboard key was pressured, being it for the program and not for the keyboard.
|
|
|
|
|
I don't think anyone here understood your question. Could you explain it better? what do you want to do? differentiate when the Click event of the Button was raised because of the user actually clicking the button or because the user pressed the Enter key?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Sorry my English is bad, more one day I learns to speek correctly. XDD
In the game, when pressuring keyboard key ENTER, open the Console. I have code of send information, what I need is simple, when pressuring the button in the program that I am creating, it will send the information that keyboard key ENTER was pressured, however I do not know to define that this keyboard key in specifies was pressured.
Thank you, for your attention and patience.
|
|
|
|
|
So, you want to simulate the Enter key being pressed when the user Clicks on your button?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
|
See SendKeys.Send[^]. It't might do what you want. And be sure to take a look at the NOTE at the very botton.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thanks.
Case that it will simulate keyboard keys of number 0~10, how to make?
|
|
|
|
|
Hi!
I would like to make a custom control with a menu that drops down when the user clicks it (sort of like a combo box) - but I can't seem to find a way to make parts of the control (the drop down menu) overlap other controls like the combobox does. Any suggestions?
|
|
|
|
|
Search MSDN or codeproject, there are many articles on doing custom control drawing.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Yeah... I've done alot of custom control drawing, but this is a bit different since it's supposed to be able to pop up over all the other controls... I guess I'll end up using a normal control that makes sure it's topmost all the time while it's visible. The best thing would be to be able to make a custom ContextMenu (since they're able to hover over other controls)
|
|
|
|
|
Ah, I understand your problem now. Have you tried setting the Region of the control? I think with that you could draw past your control bounds...
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
hello friends i m making a project in ma university and for that i need to get image from scanner and display it in the picture box in c#...i found the relative code for vc and vb but couldnt not find it for c #....i found one that was of Twain but it has copy rights ...........
so plz any bodu plz can help me and send me a code in which to get image from scanner and display it in the picture box in c# plz i will be looking forward for the code as soon as possible thnx u very much palz...tc u all
Momi
|
|
|
|
|
Hi everyone, I'm wondering about this....If you are familiar with the old DOS days, please read-on, back then in those days, if you want to protect anyone from stepping into your code (either compiled C/Pascal) [Note: No Win .NET stuff etc here], you can redirect Interrupt 3 (which was the debugger interrupt) to your own interrupt vector routine and prevent the code from being stepped into. Is there an equivalent of that in the Windows, .NET world. I'd like to be able to prevent anyone attaching a debugger to a running .NET app (process) so that they cannot find out how to bypass the routines etc....I am 100% sure there's a way to do this, without resorting to tapping into the debugger api...can anyone shed some light on this please?
Many thanks,
Tom.
#define STOOPID
#if STOOPID
Console.WriteLine("I'm stoopid!");
#endif
|
|
|
|
|
|
That doesn't enforce it. Only if the debugger explicitly wants to skip over it. Basically, it works for a .Net debugger, not an asm debugger.
Perhaps a small loader could be merged into the .Net exe that would redirect int3?
|
|
|
|
|
Hi all,
I'm using the nice example [^] and everything works fine until I got an "out of page range error" while printing the document.
Does anyone know:
a) how to suppress MSWord errors - no error popup ?
b) how to handle errors happened in Word?
c) how to reset errors and continue working ?
I tried to use for point a)
word.Visible = false;
word.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
but it doesn't have any effect - the error message is still comming up.
(have not found msdn articles)
Thanks for your response
Frank
|
|
|
|
|
Hi!
I'm using:
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.DoubleBuffer,true);
SetStyle(ControlStyles.UserPaint,true);
.....
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= 0x00000020;
return createParams;
}
}
......
protected override void OnBackColorChanged(EventArgs e)
{
// TODO: Add DivPanel.OnBackColorChanged implementation
//base.OnBackColorChanged (e);
}
, in my TranspPanel class and:
private void OnPanelDragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
DivPanel d_panel = sender as DivPanel;
Point cu=Cursor.Position;
cu=DraggingPanel.Parent.PointToClient(cu);
cu.Offset(-this.offX,-this.offY);
d_panel.Parent.Invalidate(new Rectangle(d_panel.Parent.PointToClient(DraggingPanel.Parent.PointToScreen(DraggingPanel.Location)),DraggingPanel.Size),true);
this.DraggingPanel.Location=new Point(cu.X,cu.Y);
where d_panel.parent is TransPanel.
But there are blinking...
What I should do?
|
|
|
|
|
here is full code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace wg2h
{
///
/// Summary description for WYSIWYG.
///
public class WG : System.Windows.Forms.Form
{
private Panel DraggingPanel;
private int offX;
private int offY;
private Point loc=new Point(1000,1000);
public static Form wf=new WG();
private wg2h.DivPanel p0;
private System.Windows.Forms.Label label1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public WG()
{
ResizeRedraw = true;
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.p0 = new wg2h.DivPanel();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// p0
//
this.p0.AllowDrop = true;
this.p0.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.p0.Dock = System.Windows.Forms.DockStyle.Fill;
this.p0.Location = new System.Drawing.Point(0, 0);
this.p0.Name = "p0";
this.p0.Size = new System.Drawing.Size(610, 475);
this.p0.TabIndex = 0;
this.p0.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter);
this.p0.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver);
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
//
// WG
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.ClientSize = new System.Drawing.Size(610, 475);
this.Controls.Add(this.p0);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "WG";
this.Text = "WYSIWYG";
this.Load += new System.EventHandler(this.WG_Load);
this.ResumeLayout(false);
}
#endregion
[STAThread]
public static void Main(){Application.Run(wf);}
private void OnPanelMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.offX=e.X;
this.offY=e.Y;
Panel tsender=(Panel)sender;
this.DraggingPanel=tsender;
this.DoDragDrop(tsender,DragDropEffects.Move);
}
private void OnPanelMouseLeave(object sender, System.EventArgs e)
{
}
private void OnPanelDragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect=DragDropEffects.Move;
}
private void OnPanelDragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
DivPanel d_panel = sender as DivPanel;
Point cu=Cursor.Position;
cu=DraggingPanel.Parent.PointToClient(cu);
cu.Offset(-this.offX,-this.offY);
d_panel.Parent.Invalidate(new Rectangle(d_panel.Parent.PointToClient(DraggingPanel.Parent.PointToScreen(DraggingPanel.Location)),DraggingPanel.Size),true);
this.DraggingPanel.Location=new Point(cu.X,cu.Y);
}
private void WG_Load(object sender, System.EventArgs e)
{
Control px=new DivPanel();
px.Location=new Point(0,0);
px.Size=new Size(100, 200);
px.AllowDrop=false;
this.p0.Controls.Add(px);
px.BringToFront();
px.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter);
px.MouseHover += new System.EventHandler(this.OnPanelMouseLeave);
px.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver);
px.MouseLeave += new System.EventHandler(this.OnPanelMouseLeave);
px.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnPanelMouseDown);
px=new DivPanel();
px.Location=new Point(0,0);
px.Size=new Size(100, 200);
px.AllowDrop=false;
this.p0.Controls.Add(px);
px.BringToFront();
px.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter);
px.MouseHover += new System.EventHandler(this.OnPanelMouseLeave);
px.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver);
px.MouseLeave += new System.EventHandler(this.OnPanelMouseLeave);
px.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnPanelMouseDown);
}
}
public class DivPanel:System.Windows.Forms.Panel
{
public DivPanel()
{
//Для прозрачности установим стиль
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.DoubleBuffer,true);
SetStyle(ControlStyles.UserPaint,true);
this.BorderStyle=BorderStyle.FixedSingle;
}
//Добавим к окну, при его создании, WS_EX_TRANSPARENT для прозрачности:
protected override CreateParams CreateParams
{
get
{
const int WS_EX_TRANSPARENT = 0x00000020;
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= WS_EX_TRANSPARENT;
return createParams;
}
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
// TODO: Add DivPanel.OnPaint implementation
//рисуем бордер
base.OnPaint (e);
this.BorderStyle=BorderStyle.FixedSingle;
if(this.Parent is DivPanel)e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Red)),0, 0, Width, Height);
}
//отменяем базовый метод:
protected override void OnBackColorChanged(EventArgs e)
{
// TODO: Add DivPanel.OnBackColorChanged implementation
//base.OnBackColorChanged (e);
}
}
}
DivPanels blinking ,as you see...
and nobody can tell me what's the ...
|
|
|
|
|
I was just browsing through some of the features apple's new tiger operating system. One of the features I found was the invocation of the dictionary feature implemented in Tiger. Essentially, one would place their mouse on top of a word they are interested in and they simply hold down CTRL-COMMAND-D this fires the dictionary window displaying the definition of the word in question.
This link gives a good description :
http://a1408.g.akamai.net/7/1408/7780/20050429/www.mac.com/st/1/learningcenter20050429/pdf/tiger/Tiger_Definitions.pdf
Being new to windows programming, I was wondering how could I go about mimicking such a feature in windows. For starters the dictionary application could listen for certain keypress event with a keycombination such as CTRL-SHIFT-ATL-D. One thing I can't quite figure out is that how is it possible to pass the selected text from any application into the dictionary window.
Any feedback will be appreciated.
thanks
Vee
|
|
|
|
|