|
Hi guys,
I'm writing some controls to build skin application,and I would like to apply skin to the scroll bar. Because I can not change system scroll bars I think to hide the listbox scroll bar with this code:
int sb=Convert.ToInt32(ScrollBarTypes.SB_VERT);
WindowsAPI.ShowScrollBar(_toScroll.Handle,sb,0);
In my skin scroll bar code when I want to scroll I use this code:
int scroll=Convert.ToInt32(Msg.WM_VSCROLL);
IntPtr hwnd=_toScroll.Handle;
int hiword=Convert.ToInt32(ScrollBarRequests.SB_THUMBPOSITION);
int par=Convert.ToInt32(0x10000);
int par2=65535;
Debug.WriteLine(Value);
IntPtr index=new IntPtr(((Value-1) * par) | (hiword & par2));
WindowsAPI.SendMessage(hwnd,scroll,index,new IntPtr(0));
It runs correctly but each time the listbox scrolls, the system scrollbar remains visibile
Are there other methods to scroll the listbox?
|
|
|
|
|
I work on a company that makes heavy use of the COM\ATL framework for C++ component based programming. We would like to move to .Net\C#, but haven't quite resolved how to achieve all of our criteria. Outstanding issues are:
1. Type libraries
I don't yet see a concept of a binary type definition file in C#. Every C# example I've seen that defines an interface does so in a .cs file.
public interface ISayHello
{
// define properties and methods
}
This has two problems: you cannot register your interface (tlb's can be registered) and it is editable(I like giving out tlb's, knowing that the interface won't be tampered with). Can you still use idl in C#? Can you import tlb's?
2. Registry Groups
We register our COM components using a registry groups. This allows us to programmatically query the registry for a list of our company's servers. It is very important for us to be able to filter the registry contents in this way. I think I understand that the global assembly cache now replaces the registry, but I don't see a way to programattically search it, much less search it with a group filter.
3. MTA\STA
We currently create our servers in the MTA for performance reasons, and because it's more deterministic. Is there a MTA\STA concept in .Net? Is there still a message pump?
Sorry for the long post. I'd appreciate whatever advise, links or book titles that come to mind.
Aaron
|
|
|
|
|
AaronStibich wrote:
This has two problems: you cannot register your interface (tlb's can be registered) and it is editable(I like giving out tlb's, knowing that the interface won't be tampered with). Can you still use idl in C#? Can you import tlb's?
The .cs file is just the source like a .cpp file with VC++. You will compile your code into an assembly .dll. Under the .NET Framework there are no IDL files.
AaronStibich wrote:
We register our COM components using a registry groups. This allows us to programmatically query the registry for a list of our company's servers. It is very important for us to be able to filter the registry contents in this way. I think I understand that the global assembly cache now replaces the registry, but I don't see a way to programattically search it, much less search it with a group filter.
All strongly named assemblies can be installed within the GAC (Global Assembly Cache). This would allow you to install (for example) 4 different versions of myCode.dll and they are all still accessable. I will have an article coming up soon explain more on this. You may be able to expose the meta data somehow, not sure right now.
AaronStibich wrote:
We currently create our servers in the MTA for performance reasons, and because it's more deterministic. Is there a MTA\STA concept in .Net? Is there still a message pump?
There has been a lot of fuss of deterministic finalization, most people say that it no longer exists. The .NET Framework implements garbage collection so this is kind of a touchy subject. You can override the WndProc like this:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
<font color="green">
base.WndProc(ref m);
}
Hope this helps some.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Nick Parker wrote:
Under the .NET Framework there are no IDL files
With .NET, everything is an IDL file. Remember that IDL files where used to allow marshalling accross process boundaries, now with the .NET virtual machine marshalling is everywhere to convert types according to the needs.
AaronStibich wrote:
Is there a MTA\STA concept in .Net?
You can attach the [STAThread] or [MTAThread] attribute with the entry-point of your application, but it only has an effect when this application uses COM interop.
AaronStibich wrote:
Is there still a message pump?
The current .NET CLR is a mixture of the old windows message world and the event model world (introduced by java as far as I know). So yes, you can still do so but when you are using explicit SendMessage calls or other stuff, you are in fact faking .NET.
COM components belong to the C++ world. They are not needed anymore in a .NET environment, except for legacy reasons (tons of COM/ActiveX components used in the real world).
Back to real work : D-23.
|
|
|
|
|
.S.Rod. wrote:
With .NET, everything is an IDL file.
The reason I said there were no IDL files is because just the other night Terry Leeper from MSFT gave a speech that I listened to and he said in his presentation that IDL files are no longer.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
That's correct. The release of the CLR marks the death of COM.
Back to real work : D-22.
|
|
|
|
|
.S.Rod. wrote:
That's correct. The release of the CLR marks the death of COM.
Ok, are you contradicting yourself or agreeing with me?
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
I agree with you.
Back to real work : D-22.
|
|
|
|
|
.S.Rod. wrote:
Back to real work : D-22.
Could you explain this, I think I have read it in your posts since it said D-28. What does it mean, are you counting down days or something?
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
In 21 days, I am employed again.
Back to real work : D-21.
|
|
|
|
|
.S.Rod. wrote:
In 21 days, I am employed again.
Hey, congratulations and good luck.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Is there support for using .ini files in C#? I can't seem to find it anywhere. Is there a substitute for this (I don't want to use the registry)?
Thanks for your help!
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Darryl Borden wrote:
Is there a substitute for this (I don't want to use the registry)?
How about just using an XML file, I believe this is the "way" some apps are going now because it is so easy to work with them inside the Framework.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Can you show me an example how to read\write data to a xml file?
|
|
|
|
|
Here is an article that may help:
Convert INI file to XML[^]
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Try to use this code in your app.
////////////////////////////////////////////////////
public class IniFile
{
public string path;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,string key,string val,string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath);
public IniFile(string INIPath)
{
path = INIPath;
}
public void IniWriteValue(string Section,string Key,string Value)
{
WritePrivateProfileString(Section,Key,Value,this.path);
}
public string IniReadValue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path);
return temp.ToString();
}
}
=====================
http://wasp.elcat.kg
|
|
|
|
|
Are there any good Class or Collection tutorials out and about? I cannot find any on this site, does anyone have some links?
thanks =)
|
|
|
|
|
Hi *.*!
I'm a beginner on C# and don't seem to be capable to figure out on how to do a splash screen. What I have is a Main Window which takes some time to load because it does quite some stuff in the OnLoad. Because of this I'd like to display a so-called splash screen which is loaded and shown when the application starts and as soon as all the initializations are done, is unloaded again. Can anybody pls. advise? Don't need the source code (would be fine though ) but just a hint on how to do this.
Thanx in advance!
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
Create a form, remove the border, put a timer on it, in the Elapsed event, Close the form.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
Thanks for your answer, but:
1. you don't have control over the loading progress. What I wanted to do is to display the splash screen only as long as my form needs to load. No longer no shorter.
2. Another issue with those splash screens ist that they should stay on top of all windows in your application. If you do it a modal dialog, processing (loading the main form) will not continue as long as the form is shown, if you do it with .TopMost=true and .Show, you have it hanging over each and every application. As well not quite what I would need.
After giving the whole thing a good thought, I came to the point that the only solution is to spawn a new thread when the main window starts loading, show a form in this thread and stop the thread when I'm through with my stuff and the main wnd is ready to be shown.
Agree?
Thanks a lot,
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
Instead of setting your main form as the start up object, try creating a moudle (what ever they are called now) and put the sub main there. In there , display your spalsh screen, the display your main dialog. When the main dialog is done loading, kill the splash screen.
|
|
|
|
|
Is it possible to serialize an Exception derived class? When I try to add an exception to a System.Messaging.Message object (which internally serializes the object to XML) I receive the following error:
System.InvalidOperationException: There was an error reflecting 'Send.DALException'. ---> System.InvalidOperationException: The property 'Source' on type 'System.Exception' cannot be serialized because it is decorated with declarative security permission attributes. Consider using imperative asserts or demands in the property accessors.
What does this mean? Can I get around it?
|
|
|
|
|
hi,
i use this exception class in my remoted components. this execption class is serializable and should help you with your problem.
[Serializable]
public class ComponentException: ApplicationException, ISerializable
{
public ComponentException()
{
}
public ComponentException(string message)
: base(message)
{
}
public ComponentException(string message, Exception inner)
: base(message, inner)
{
}
//Deserialization constructor.
public ComponentException (SerializationInfo info, StreamingContext context)
: base( info, context)
{
}
}
hope it helps
franz
|
|
|
|
|
Thanks for the reply. Message queuing must try to serialize the object differently to your project because I still get an error. Its complaining it cant reflect the class because of security? I just have a wizard created Windows Forms project and have done nothing with security. Am I missing something? Heres a quick sample of code:
<br />
System.Messaging.Message msgRequest = new System.Messaging.Message();<br />
DALException apex = new DALException("Database Error", inner);<br />
msgRequest.Body = apex;<br />
msgRequest.Label = "Test";<br />
requestQ.Send(msgRequest);
System.InvalidOperationException: There was an error reflecting 'Send.DALException'. ---> System.InvalidOperationException: The property 'Source' on type 'System.Exception' cannot be serialized because it is decorated with declarative security permission attributes. Consider using imperative asserts or demands in the property accessors.
|
|
|
|
|
hm, apperently your problem is not with the serializer but with code access security.
there is a tutorial available in the online help focusing on declarativ and imperativ code access security: "ms-help://MS.VSCC/MS.MSDNVS/csref/html/vcwlkSecurityTutorial.htm#vcwlksecuritytutorialsuppressingsecurity" or type "Security Tutorial" in the search screen of the online help.
i didn't have time to look into code access security up to now, so i wont be much help on this topic. if you find a solution to this problem it would be great if you drop me a mail.
the help also states that a default XMLMessageFormater is used if you do not provide your own. perhaps you could write your own XmlMessageFormatter class and let the message queue use this one instead of the default.
cheers
franz
|
|
|
|