|
Hi All!!!
I have to design an application like access report designer. Where we would have drag n drop contorls like Text Boxes, Check Boxes, Radio Buttons, Labels etc and then have to preview them,select them, resize them and so on.
I was thinkin about Creating standard Contorls but then I realized that its difficult to handle them, for example if you click a textbox to select it for resizing, it will start funtioning, similary if u select checkbox to resize, it will eb checked. And their preview wasnt posisble a well.
So i created my own custom controls using GDI+ whose preview is also possible in PrintPreviewDialog.
Any help (even if is very basic and just provide an idea to take start) will be highly appriciated.
Thanx in Advance
sorry for my bad English.
|
|
|
|
|
Itanium wrote:
Any help (even if is very basic and just provide an idea to take start) will be highly appriciated.
When you click on the control, trap the click by handling the "OnClick" event. Draw a frame around the control and set the focus to the control. You might need to trap the message itself rather than the event and "steal" it from the control.
I've been wanting to write a generic form layout tool for ages, but have never gotten around to it.
Want to collaborate?
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
since he is going to use it in a report i think it would be unwise to use actual window controls.
it would be better to create your own gdi+ based 'controls' that render themselves onto a graphics/dc
using true controls he will get a hard time to render them in a good way to the printer , and if the report is big , he will endup with a zillion hwnds that eats resources..
if you want to do a form designer , you should take a look aT:
http://www.windowsforms.com/default.aspx?tabindex=5&tabid=47&ItemID=13&mid=142[^]
//Roger
|
|
|
|
|
Roger J wrote:
using true controls he will get a hard time to render them in a good way to the printer , and if the report is big , he will endup with a zillion hwnds that eats resources..
Those are great points. My thinking cap isn't properly attached this morning.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hello Marc!!
Infact i started work on the deisgner few days back. I used the same way as Rojer told. I have made my own custom control classes hierarchy and renedring them both on design time and at preview.
Here i posted because( i was studying Java Reflection API's in previous days there we can have all classes , properties methods etc i htought that if anyone have used same kind of thing in .net (if available))
so that if i could found a better way but i came to know htat i am going in right direction.
You said about "Collboration"...
Sure ...why not...
sorry for my bad English.
|
|
|
|
|
Is there any prior Delphi developers here ? I'm trying to translate an program from Delphi to C#. Most of the program is translater now, only the worst part is shown here. P.S. Even if youre not familiar with Delphi, please take a look anyway ...
The problematic part in the code below is mostly the part GetBook procedure. It takes a record TBookInfo (struct in C#) from an array (ArrayList would have a best use in here) and creates and instance of TMyBook type and assignes it to a varable in the record. The tricky part here is that the instance is created the same type as another variable is - TMyBookClass (witch is class of TMyBook). I have no ideas how to do that in C#. Any ideas (some code would be very nice) ?
Can anyone help me with this ?
<br />
program Project;<br />
<br />
{$APPTYPE CONSOLE}<br />
<br />
uses<br />
SysUtils, Classes;<br />
<br />
type<br />
TMyBook = class<br />
private<br />
FName: string;<br />
public<br />
constructor Create(const AName: string); virtual;<br />
property Name: string read FName;<br />
end;<br />
<br />
TMyBookClass = class of TMyBook;<br />
TMyNewBook = class(TMyBook);<br />
<br />
TBookInfo = record<br />
Name: String;<br />
BookInstance: TMyBook;<br />
BookClass: TMyBookClass;<br />
end;<br />
<br />
var<br />
ActiveBook: TMyBook;<br />
Books: array of TBookInfo;<br />
<br />
constructor TMyBook.Create(const AName: string);<br />
begin<br />
FName := AName;<br />
end;<br />
<br />
function FindBook(const AName: string): Integer;<br />
begin<br />
for Result := 0 to Length(Books) - 1 do<br />
if CompareText(Books[Result].Name, AName) = 0 then Exit;<br />
Result := -1;<br />
end;<br />
<br />
procedure RegisterBookInfo(const AName: string; ABookClass: TMyBookClass);<br />
var<br />
Index: Integer;<br />
begin<br />
Index := Length(Books);<br />
SetLength(Books, Index + 1);<br />
with Books[Index] do<br />
begin<br />
Name := AName;<br />
BookClass := ABookClass;<br />
BookInstance := nil;<br />
end;<br />
end;<br />
<br />
function GetBook(const AName: string): TMyBook;<br />
var<br />
Index: Integer;<br />
begin<br />
Index := FindBook(AName);<br />
with Books[Index] do<br />
begin<br />
Assert(BookInstance = nil);<br />
BookInstance := BookClass.Create(Name);<br />
Result := BookInstance;<br />
end;<br />
end;<br />
<br />
procedure SetActiveBook(const ABookName: string);<br />
begin<br />
ActiveBook := GetBook(ABookName);<br />
end;<br />
<br />
begin<br />
RegisterBookInfo('New Book', TMyNewBook); <br />
SetActiveBook('New Book');<br />
end.<br />
Regards, Desmond
|
|
|
|
|
It looks like all the procedures and functions are designed to perform actions on array elements or instances of TMyBookClass. The array Books contains a set of records, but each record contains a pointer to a BookInstance and a BookClass. So, for example, the GetBook method find the array index of a book whose name is stored in AName, and then, with that array element, it sets the BookInstance pointer to a new TMyBookClass and returns that BookInstance.
But that's just my opinion, I could be wrong.
|
|
|
|
|
And how exacly could I do that in C# (could you show it to me in C# please) ?
|
|
|
|
|
OK, just for fun, I re-wrote your delphi code in C#. Not that I'm sure this implementation is even correct, or that it does anything desirable, but it will compile. So, in TMyBookClass.cs, we have:
using System;
using System.Collections;
namespace Books
{
public abstract class TMyBook {
string FName;
public abstract TMyBook Create(string AName);
public virtual string Name {
get { return FName; }
set { FName = value; }
}
}
public class TMyBookClass : TMyBook {
TMyBook ActiveBook;
ArrayList Books = new ArrayList();
public struct TBookInfo {
public string Name;
public TMyBook BookInstance;
public TMyBookClass BookClass;
}
public TMyBookClass(string AName){
this.Create(AName);
}
public override TMyBook Create(string AName) {
this.Name = AName;
return this;
}
public int FindBook(string AName) {
for(int result = 0; result < Books.Count; result++) {
TBookInfo bi = (TBookInfo)Books[result];
if (bi.Name == AName) { return (result); }
}
return -1;
}
public void RegisterBookInfo(string AName, TMyBookClass ABookClass) {
TBookInfo bi = new TBookInfo();
bi.Name = AName;
bi.BookClass = ABookClass;
bi.BookInstance = null;
Books.Add(bi);
}
public TMyBook GetBook(string AName) {
int index;
index = FindBook(AName);
TBookInfo bi = (TBookInfo)Books[index];
return bi.BookClass.Create(Name);
}
public void SetActiveBook(string ABookName) {
ActiveBook = GetBook(ABookName);
}
}
}
Then, in the main class of a console application, you could...
TMyBookClass TMyNewBook = new TMyBookClass("New Book");
TMyNewBook.RegisterBookInfo("New Book", TMyNewBook);
TMyNewBook.SetActiveBook("New Book");
|
|
|
|
|
I have string array, I converted that one to char array
I am trying to access values of character array and trying to convert them to integer.
code follows here
string rs="999";
char[] rs1=rs.ToCharArray();
int i;
int sum=0;
for(i=0;i
|
|
|
|
|
GetOn&GetGoing wrote:
I am getting the address value...
Try the following:
int sum = 0;
int i = 0;
string rs = "999";
char[] rs1 = rs.ToCharArray();
foreach(char c in rs1)
{
i = Convert.ToInt32(c);
sum += 10 * i;
Console.WriteLine(sum.ToString());
}
- Nick Parker My Blog
|
|
|
|
|
|
Hi to all
I want to convert string of numbers to integer without using any in built functions like convert or parse
for ex "666"=666
|
|
|
|
|
How else would you do that, then?
What's wrong with Convert.ToInt16("666") or int.Parse("666")?
Why 666?
|
|
|
|
|
Convert.ToInt16("666") Will not convert to an integer, but to a short.
You can also use Int32.Parse("666").
It this is hell (666), then imagine the rest
|
|
|
|
|
|
What, like this?
int i = 1234;
string j = i.ToString();
System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
byte[] b = ae.GetBytes(j);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int k = 0; k < b.Length; k++){
sb.Append(b[k]);
sb.Append(", ");
}
Console.WriteLine(sb.ToString());
|
|
|
|
|
Use BitConverter . It will convert any simple data type to byte and reverse. (Very useful for network transmissions )
|
|
|
|
|
What hook will allow me to global catch when a control looses focus?
|
|
|
|
|
|
Are there any built in .NET functions for dealing with relative file paths? Specifically: if I have two absolute file paths:
<br />
string fileNameA;<br />
string fileNameB;<br />
and I want to change fileNameB to be relative to fileNameA. Is there any way to do this with .NET, or should I just roll my own? Even just a way to tell fileOpenDialogs to return string names relative to the current working directory would be helpful.
Thanks
Dave
|
|
|
|
|
How can I get the unmanaged pointer of a managed method in C# so that I can store it in an integer within unmanaged memory? Also, how can I wrap an object around a pointer, with In/Out capabilities? It sounds kind of complicated, but I believe it is possible somehow. I'm trying to use a DLL in my program, which creates and uses a custom structure (in this case in the unmanaged memory). Luckily, there is a function in the DLL which allows me to retrieve the address of the structure, and I know all of the members in that structure through documentation. The part that trips me up is that the structure stores pointers to functions, and in order to use the DLL the way I would like, I want to change those pointers to my managed C# methods. As for the structure itself, I would like to wrap a managed structure around a pointer so that I can access the fields within it as well as write to those fields, kind of like a two-way link between the managed and unmanaged memory...
I only wish there were an easier way to explain all this. Does anybody know what I'm talking about?
|
|
|
|
|
|
I wonder if there is a difference between sending a broadcast or a multicast message on a single network (IE does not require routing).
|
|
|
|
|
I am calling an external app and redirecting the StandardOutput and StandardError streams so that I can capture them and display them in a TextBox. My app hangs in my timer Tick method (set to 20ms) when there is a lot of data on the StandardError stream, it hangs in the ReadLine() method with no warnings or output or anything. It just sits there and doesn't do anything, this also happens with the other Read methods EXCEPT for ReadToEnd() which will work. Unfortunately ReadToEnd() doesn't allow me to dynamically update the TextBox with the output as it comes in from the external process (using Process). When there's only a few lines of output it works fine, so my guess is there's some overflow or something with the data coming in too fast, but I can't figure it out.
I've tried many different things to get this to work with no luck, so am posting here hoping that this is a known issue or some way around this. TIA
|
|
|
|