|
Either use the IL disassembler (ildasm.exe) from the .NET Framework SDK if you now how to read IL (Intermediate Language) or a good decompiler like .NET Reflector[^] to examine how those methods work. This is a handy approach to figuring out how code works. Some companies will obfuscate their code making it more difficult, but not impossible. Microsoft does not obfuscate their .NET FCL assemblies.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well, I decompiled the Textbox, Richtextbox, and TextboxBase from the .Net framework a while back. The problem was, the functions that I want use API to get the info.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
That's right! Most of the .NET FCL classes are wrappers around API calls...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I visually generated control,
variable in code appears.
But I have class derived from that type,
(extend functionality to reuse),
by which I want to handle visual part,
I change type to derived, ...
but editor not see precise type and removes control from the form.
So,
How to connect variable to control in such case ?
Thanks
|
|
|
|
|
I'm not sure I understand you (your question is very difficult to read, you might try elaborating a bit), but if you want to change the Type in your container (Form , UserControl , whatever), then make sure both the variable type declaration and the instantiated Type (in the InitializeComponent method) are the same, derived Type. Also make sure that that Type has been compiled and is either in the same project or a dependency project that has been referenced by your current project (when you right-click on the project and select Add Reference, select the project tab and add the project to make sure that a build dependency is established and that the build configuration (i.e., release, debug, whatever)is always in sync).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
???????????????????????????????????????????
This doesn't make any sense what-so-ever...
Are you saying that you created your own UserControl class, inheriting from an existing control?
Did you drop YOUR control on the form, or drop the base control that you inherited from? If you want to use YOUR version of the control, you'll have to add it to the Toolbox, then drag that onto your form, not the control you inherited from.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Witout new control creation - in a visual way,
I can not do it programmatically - to just add some small functions,
in inherited class?
but continue to edit all other properties - visually.
(control disappear from editor)
As extending Buttton in other languages, pure programmatically ?
|
|
|
|
|
What your saying is VERY difficult to understand.
Are you saying that you want to set the properties of a control in a Properties Page like Visual Studio has in the bottom right corner of the screen? Is this control one that you wrote?
Are you trying to write your own extended Button class and have your extended properties show up in the Property Page?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Im trying to make a specification here at work for how we should write our classes.
what i mean is for readabillity / make it as easy as possible to find the correct parts of your code.
some might suggest an apporach like this
class
{
//variables
//events
//constructor(s)
//propertis
//methods
//overrides
//interfance implementations
//nested casses
}
or
class
{
//variables
//events
//constructor(s)
//propertis (all propps , overriden propps , interface implemented propps)
//methods (all methods , overriden methods, interface implemented methods)
//nested casses
}
do you guys have any other suggestions?
what about regions ?
i tend to add regions to everything i do , but when im done it usually looks like crap with lots of folded blocks in it.
anyone seen any code that you think "it doesnt get any better than this" (layoutwise/readabillity that is) ??
//Roger
|
|
|
|
|
I've once read the following structure in a book and use it since that time.
All parts are coded as a region and i try not to have more than two nested regions.
class
{
class variables
instance variables
construction, destruction
class methods
instance methods (further grouping depending on what the methods do)
interface implementations
}
www.troschuetz.de
|
|
|
|
|
You've missed constants; I always put them up at the top.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi all.
I'm trying to use WNetAddConnection2 to connect to a printerqueue on "lpt2:" or to some shared folder on a server on "u:" (or some other "free letter"). I have found several pieces of sample code on the net, and I have a working piece in managed C++, but in c# I get the error "Attempt to access invalid address". From what I understand the program does not recognise the local resource
Some code snippets:
Declarations:
[StructLayout(LayoutKind.Sequential)]
public class NETRESOURCE
{
public long dwScope = 0;
public long dwType = 0;
public long dwDisplayType = 0;
public long dwUsage = 0;
public string lpLocalName = null;
public string lpRemoteName = null;
public string lpComment = null;
public string lpProvider = null;
};
[DllImport("mpr.dll", EntryPoint="WNetAddConnection2")] public static extern int WNetAddConnection2A(NETRESOURCE lpNetResource, string lpPassword, string lpUserName, long dwFlags);
"Working code":
ntRec=new NETRESOURCE();
ntRec.lpRemoteName="\\\\SW\\cn=ADR-HP.ou=Printers.ou=HE.o=SW";
ntRec.dwType=RESOURCETYPE_PRINT;
ntRec.lpLocalName="lpt2:";
ntRec.lpProvider=null;
intRet=WNetAddConnection2A(ntRec, null,null, CONNECT_INTERACTIVE);
The c++ code that works looks like this:
String* pstrPrinter="\\\\SW\\cn=ADR-HP.ou=Printers.ou=HE.o=SW";
String* pstrPort="lpt2:";
TCHAR* pszName=(TCHAR*)(Marshal::StringToHGlobalAnsi(pstrPort)).ToPointer();
TCHAR* pszConn=(TCHAR*)(Marshal::StringToHGlobalAnsi(pstrPrinter)).ToPointer();
ntRec.lpRemoteName=pszConn;
ntRec.dwType=RESOURCETYPE_PRINT;
ntRec.lpLocalName=pszName;
ntRec.lpProvider=NULL;
dwRet=WNetAddConnection2(&ntRec, NULL,NULL, CONNECT_INTERACTIVE);
WNetCancelConnection works in C# thought, just using "lpt2:"
Any good ideas?
Thanks
/EnkelIk
|
|
|
|
|
Hm. What can I say? Going over the code again, and replacing the long with enumerators in NETRESOURCE -I had some problem with these before but I can't quite remember what. Having done this it works like a charm.
Can't believe I have spent hours to solve this!
Sorry for taking your time
Thanks
/EnkelIk
|
|
|
|
|
DWORD values should be passed as either Integer , Int32 , or UInt32 types in VB.ET and Long type in VB6.
VB6 Long = VB.NET Integer
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm reading an Offic 2000 Excel spreadsheet through a c# app and I would like to know the limits of the populated cells, rather than itterating through until I read an empty cell (this is not a good mathod because a sheet can have gaps in it)
Is there a method that will return a single range covering the populated cells?
|
|
|
|
|
To answer my own question:
WorkSheet.UsedRange;
but this range includes cells have formatting, but may be empty.
|
|
|
|
|
Hello NG, I search for information about c# and Nero. i will burn cds with nero version 5.5.x.x. can you help me, how i can start programming.
I've found a tutorial about c# and nero verion 6 and highter, but its not working with earlier versions same 5.5.x.x
thx bjoerg
|
|
|
|
|
Is there anyway to bind the scroll wheel of the mouse to a verticle scrollbar?
For example, in a textbox, if the user "scrolls down" with the middle mouse button, how can I detect that and then update the scrollbar accordingly?
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
To detect scrolling use the MouseWheel event which occurs when the mouse wheel moves while a control has focus.
See the documentation for further information on handling this event.
www.troschuetz.de
|
|
|
|
|
Ahh. Thanks for the info.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
I am getting
An object reference is required for the nonstatic field, method, or property 'AMPE_Server.AMPE_Service.ReadRequest()'<br /> in the following method.
<br />
private static void ProcessRequest()<br />
{<br />
while ( true )<br />
{<br />
Thread requestThread = new Thread( new ThreadStart( ReadRequest ) );<br />
requestThread.Start();<br />
}<br />
}
which refers to the following method
<br />
private void ReadRequest()<br />
{<br />
AMPE_Server.Communication.Request request = new AMPE_Server.Communication.Request()<br />
lock (this)<br />
{<br />
request = (AMPE_Server.Communication.Request) queueRequests.Dequeue();<br />
}<br />
}
What the hell have I done wrong? This learning threading is hard as hell after programming with VB for the past 10 years.
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
private void ReadRequest()
here is your problem:
you need to have a static function to use threads, as they are independent proccess
so write private static void ReadRequest() instead, ofcourse you have to change your code inside the function too since the method is now static.
Hope that helps!
flow
|
|
|
|
|
flow5555 wrote:
you need to have a static function to use threads, as they are independent proccess
That's not the case!
www.troschuetz.de
|
|
|
|
|
Thanks for the help. I redefined the method as static and had to remove the lock code. Can you explain what the lock command does?
Regards,
Eric C. Tomlinson
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
This isn't a threading problem and you don't need static methods to use threads.
What you've done wrong is that you pass the ReadRequest method to the ThreadStart delegate without using an object.
<br />
Thread requestThread = new Thread( new ThreadStart( ReadRequest ) );<br />
As the ReadRequest method isn't static this fails. Either declare your method static or use an object.
<br />
Thread requestThread = new Thread( new ThreadStart( obj.ReadRequest ) );<br />
www.troschuetz.de
|
|
|
|