|
Hello,
I created a COM object in ATL, that copy the screen and
retrurn it, by: HBITMAP struct.
When I add a reference, the: .NET, convert this type to:
IntPtr.
OK, I call to the function, get the: IntPtr. And use:
Bitmap bmp= Image.FromHbitmap(myIntPtrObj);
But than I get this exception:
System.Runtime.InteropServices.ExternalException
with this describe:
A generic error occurred in GDI+.
Please help me, how to solve this exception...
Thank's alot,
Itay.
|
|
|
|
|
If I programmatiacally want to determine whether .NET framework is installed on a computer and if so what version of .NET, how do I do this?
The project can not use .NET naturally since it also has to run on computers where .NET has not yet been installed. I've looked in the registry and found that I can use "RegOpenKeyEx()" on the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0", but there must be a better way, since this call will fail if the user is running v1.1 . So how can I decide if and what version of .NET is installed on a computer?
Regards
/EnkelIk
|
|
|
|
|
If you app is being accessed or downloaded from the web, you can check the user agent of the request object. .Net adds the clr and version number to the user agent. Check out http://www.asp.net/webmatrix/download.aspx?tabindex=4 download section which uses the user agent to detect whether or not .net is installed. It's quick and simple. Hope this helps.
|
|
|
|
|
On the client-side, check out whether mscoree.dll exists (it's in <winsysdir>). That's the first thing a .NET app loads (to host the CLR).
Regarding the .NET version, you can lookup the registry : HKLM\Software\Microsoft\NET Framework Setup\Product\xxx with values defined as for instance :
Package="Full"
ProductLanguage="1033"
Version="v1.0.3705"
Version is like this
1 : major
0 : minor
3705 : build
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
You could also check the for the existence of the path:
%windir%\Microsoft.NET\Framework\v1.0.3705
Ragards
Chris
|
|
|
|
|
Hi, i want to develop an application that use scriptable configuration file, like Macromedia Dreamweaver MX.
In Dreamweaver MX you can modify every dialog boxes just in modify a HTML/Javascript source. A windows dialog box is an HTML form, and you can't see the difference.
I just want to know what is this technology ? Is it .NET who give this capacity to do that ? A library ? or is Macromedia who invent that ?
Thank you for your answer.
gerti@hotmail.com
|
|
|
|
|
How do I create an off screen graphics object?
Basically, I want to draw some stuff to an off screen bitmap and them blt the lot to the main window graphics object.
This is NOT for double buffering. I need to be able to compose a small scene using transparency and then blt the translarent bitmap over the main screen which also has been drawn onto.
Any ideas gratefully accepted!
Pete
|
|
|
|
|
The System.Drawing namespace is full of stuff for this kind of thing. Between the Bitmap, Image and Graphics objects, you should be pretty well sorted.
Paul
Life is just a sexually transmitted desease - Matthew Wright (ex-journalist, TV presenter) 10-Oct-02
I finally have a sig! - Paul Riley (part-time deity) 10-Oct-02
|
|
|
|
|
Hi. Thanks for the reply.
Yeah, I've already got a lot of drawing going on, but I'm just using the Pain(t) events Graphics object for now and I cant find anything that will give ne a graphics object pointing to an off screen buffer or Bitmap...
?
Pete
|
|
|
|
|
Just create a Bitmap object, using whichever of its multitude of constructors is most use for you, then if you need a Graphics object use Graphics.FromImage(MyBitmap).
Paul
Life is just a sexually transmitted desease - Matthew Wright (ex-journalist, TV presenter) 10-Oct-02
I finally have a sig! - Paul Riley (part-time deity) 10-Oct-02
|
|
|
|
|
You beauty!
Have now got some piss simple test code working. I didn't even think to look through the static members of the Graphics class.
For anyone else trying this. Heres some Very simple code...
Thanks
Pete
private void ctlSoundScene_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Bitmap oBitmap = new Bitmap(100, 100 ,e.Graphics);
Graphics oBuffer = Graphics.FromImage(oBitmap);
oBuffer.FillRectangle(new SolidBrush(Color.DarkMagenta), 10,10,30,30);
e.Graphics.DrawImage(oBitmap, 10,10);
...
...
...
|
|
|
|
|
Hi.
In my organisation we want to run an application from a server on the co-workers computers when they log-on to the local intranet, to register that they have loged-on, set the printer connections and so on. In order to be able to do this we want to set the permission level on the machines for the Local Intranet to FullTrust.
I'm trying to create an application that installed locally will do this. I have been able to create a new child codegroup that gives FullTrust to the directory where the inlogg-application is situated, but efforts changing the permission set for the LocalIntranet_Zone is so far without success.
The sample code below shows what I have done:
penumLevels=SecurityManager::PolicyHierarchy();
while (penumLevels->MoveNext())
{
try
{
pPolLevel = __try_cast <policylevel*> (penumLevels->Current);
}
catch(System::InvalidCastException* pcatchException)
{
MessageBox::Show(pcatchException->get_Message());
}
// Positioning at root level
pGroup =pPolLevel->RootCodeGroup;
// Find Machine Level Policy
pstrTmp=pPolLevel->Label->ToString();
if ( pstrTmp->Compare(pstrTmp,"Machine")==0)
{
//Find All Code codegroup
pstrTmp=pGroup->MembershipCondition->ToString();
if(pstrTmp->Compare(pstrTmp,"All code")==0)
{
//Loop through the children to find LocalIntranet_Zone
pList=pGroup->get_Children();
sCount=pList->get_Count();
for(sIndex=0;sIndex<scount;sindex++)
{
="" try
="" pchildgroup="__try_cast" <unioncodegroup*="">(pList->get_Item(sIndex));
}
catch(System::InvalidCastException* pcatchException)
{
MessageBox::Show(pcatchException->get_Message());
}
pstrTmp=pChildGroup->get_Name();
if(pstrTmp->Compare(pstrTmp,"LocalIntranet_Zone")==0)
{
//Getting the FullTrust permission set
pFullPerm=pPolLevel->GetNamedPermissionSet("FullTrust");
//Checking what is the present permission set
pstrTmp=pChildGroup->get_PermissionSetName();
//Create a new policy statement with the desired trust level
Security::Policy::PolicyStatement *pPolicy;
pPolicy=new Security::Policy::PolicyStatement(pFullPerm);
//Set the new policy
pChildGroup->set_PolicyStatement(pPolicy);
//And save changes System::Security::SecurityManager::SavePolicy();
//And again checking what the permission set is
//to make sure it has been changed
pstrTmp=pChildGroup->get_PermissionSetName();
}
}
}
}
}
When I check the name of the permission set the second time it is FullTrust, quite as I want it to only this does not have any impact on the real setting, the local intranet does still not have FullTrust status. Is there something preventing the level from being changed to a higher trustee level or am I missing something?
Best regards
/EnkelIk
|
|
|
|
|
Hey guys,
I'm looking for material depicting the current adoption rate of the .NET framework in the industry. If anyone has come across anything usefull in this regard, I will greatly appreciate it.
- Tariq
|
|
|
|
|
I haven't seen anything but I would imagine that in the current slump it's quite low.
Kevin
|
|
|
|
|
Well how about info on the existing developer movement, i mean what portion of the vb pool going to .net etc. I immagine codeproject should have some info on this.
- Tariq
|
|
|
|
|
I don't recommend switching if you have alot of code to support (existing) or if you are considering porting everything. It's not nearly as easy a migration as Microsoft might have you think. However, if the code you're writing is mostly new, .NET is wonderful, whatever the language. I work for a startup company and there's simply no way we'd ever have met our deadlines if I wrote all our code in VB6 and/or C++.
.NET makes VB wonderful and ASP glorious.
|
|
|
|
|
The following C# code is supposed to be an extended System.Windows.Forms.Panel class that provides a very basic implementation of the panels that Windows XP uses (when you take away the folder view in Explorer).
CollapsiblePanel simply contains two labels, one docked to the top for a title, and another anchored to the top right to display an expand/collapse image (the ImageList is exposed as a public property of the class).
At first glance, when you add a CollapsiblePanel to a Form it looks fine and seems to work okay. However, as soon as you add controls to the panel, the top right label with the image disappears
Any ideas why?
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Salamander.Windows.Forms
{
public class CollapsiblePanel : System.Windows.Forms.Panel
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label labelExpand;
private System.Windows.Forms.Label labelTitle;
private int panelHeight;
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.labelTitle = new System.Windows.Forms.Label();
this.labelExpand = new System.Windows.Forms.Label();
this.SuspendLayout();
this.labelTitle.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelTitle.Cursor = System.Windows.Forms.Cursors.Default;
this.labelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.labelTitle.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelTitle.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(200, 24);
this.labelTitle.TabIndex = 0;
this.labelTitle.Text = "Title";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.labelExpand.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
this.labelExpand.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelExpand.Cursor = System.Windows.Forms.Cursors.Hand;
this.labelExpand.Location = new System.Drawing.Point(17, 17);
this.labelExpand.Name = "labelExpand";
this.labelExpand.Size = new System.Drawing.Size(24, 24);
this.labelExpand.TabIndex = 1;
this.labelExpand.Click += new System.EventHandler(this.labelExpand_Click);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelTitle,
this.labelExpand});
this.ResumeLayout(false);
}
#endregion
public CollapsiblePanel() : base()
{
this.components = new System.ComponentModel.Container();
InitializeComponent();
this.BackColor = SystemColors.ControlLightLight;
this.labelExpand.Location = new System.Drawing.Point(this.Width - this.labelExpand.Width, 0);
this.labelExpand.BringToFront();
this.panelHeight = this.Height;
}
[Category("Title")]
public string TitleText
{
get
{
return this.labelTitle.Text;
}
set
{
this.labelTitle.Text = value;
}
}
[Category("Title")]
public Color TitleBackColour
{
get
{
return this.labelTitle.BackColor;
}
set
{
this.labelTitle.BackColor = value;
this.labelExpand.BackColor = value;
}
}
[Category("Title")]
public Color TitleForeColour
{
get
{
return this.labelTitle.ForeColor;
}
set
{
this.labelTitle.ForeColor = value;
}
}
[Category("Title")]
public Font TitleFont
{
get
{
return this.labelTitle.Font;
}
set
{
this.labelTitle.Font = value;
}
}
[Category("Title")]
public ImageList ImageList
{
get
{
return this.labelExpand.ImageList;
}
set
{
this.labelExpand.ImageList = value;
}
}
[Category("Title")]
public int ImageIndex
{
get
{
return this.labelExpand.ImageIndex;
}
set
{
this.labelExpand.ImageIndex = value;
}
}
private void labelExpand_Click(object sender, System.EventArgs e)
{
if((null != labelExpand.ImageList) && (labelExpand.ImageList.Images.Count >=2))
{
if(0 == labelExpand.ImageIndex)
{
this.panelHeight = this.Height;
this.Height = labelTitle.Height;
labelExpand.ImageIndex = 1;
}
else
{
this.Height = this.panelHeight;
labelExpand.ImageIndex = 0;
}
}
}
}
}
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
You may want to contact Nnamdi Onyeyiri. He's done a panel bar just like Windows XP's. He's still working out a few bugs, but I'm sure that he'd be glad to help you out.
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
|
Hi.
I can't recreate your exact problem but I've got it working, as I think you want. There are a couple of things I've changed.
I think you were having trouble with the parent form calling SuspendLayout while it set the properties of you Panel. All I've really done is added an event handler for the Resize event of you panel. It now explicitly sets the position of the labelExpand control.
Also, added a touch of code to the ImageList set. Just displays the first item when an ImageList is assigned to it.
Other than that, it works ok. I can put other controls on it no problem and it expands/contracts correctly.
One thing I dont like about C# is everyones tendancy to write
this.blah = this.control.property.blah;
when this would be prefectly readable
blah = control.property.blah;
The full source follows...(minus the Namespace) Hope this helps.
Unless your more adept with the IDE your going to have to paste this all into a new HTML doc and then copy/paste out from there into a c# doc. Pasting straight from IE to the c# class always removes all the CRLFs for me
Pete Bassett
public class CollapsablePanel : System.Windows.Forms.Panel
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label labelExpand;
private System.Windows.Forms.Label labelTitle;
private int panelHeight;
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.labelTitle = new System.Windows.Forms.Label();
this.labelExpand = new System.Windows.Forms.Label();
this.SuspendLayout();
this.labelTitle.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelTitle.Cursor = System.Windows.Forms.Cursors.Default;
this.labelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.labelTitle.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelTitle.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(200, 24);
this.labelTitle.TabIndex = 0;
this.labelTitle.Text = "Title";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.labelExpand.Anchor = System.Windows.Forms.AnchorStyles.None;
this.labelExpand.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.labelExpand.Cursor = System.Windows.Forms.Cursors.Hand;
this.labelExpand.Location = new System.Drawing.Point(229, 142);
this.labelExpand.Name = "labelExpand";
this.labelExpand.Size = new System.Drawing.Size(24, 24);
this.labelExpand.TabIndex = 1;
this.labelExpand.Click += new System.EventHandler(this.labelExpand_Click);
this.Anchor = System.Windows.Forms.AnchorStyles.None;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelTitle,
this.labelExpand});
this.Resize += new System.EventHandler(this.CollapsablePanel_Resize);
this.ResumeLayout(false);
}
#endregion
public CollapsablePanel() : base()
{
this.components = new System.ComponentModel.Container();
InitializeComponent();
this.BackColor = SystemColors.ControlLightLight;
labelExpand.BringToFront();
}
[Category("Title")]
public string TitleText
{
get
{
return this.labelTitle.Text;
}
set
{
this.labelTitle.Text = value;
}
}
[Category("Title")]
public Color TitleBackColour
{
get
{
return this.labelTitle.BackColor;
}
set
{
this.labelTitle.BackColor = value;
this.labelExpand.BackColor = value;
}
}
[Category("Title")]
public Color TitleForeColour
{
get
{
return this.labelTitle.ForeColor;
}
set
{
this.labelTitle.ForeColor = value;
}
}
[Category("Title")]
public Font TitleFont
{
get
{
return this.labelTitle.Font;
}
set
{
this.labelTitle.Font = value;
}
}
[Category("Title")]
public ImageList ImageList
{
get
{
return this.labelExpand.ImageList;
}
set
{
this.labelExpand.ImageList = value;
if(labelExpand.ImageList != null)
if(labelExpand.ImageList.Images.Count > 1)
ImageIndex = 0;
}
}
[Category("Title")]
public int ImageIndex
{
get
{
return this.labelExpand.ImageIndex;
}
set
{
this.labelExpand.ImageIndex = value;
}
}
private void labelExpand_Click(object sender, System.EventArgs e)
{
if((null != labelExpand.ImageList) && (labelExpand.ImageList.Images.Count >=2))
{
if(0 == labelExpand.ImageIndex)
{
this.panelHeight = this.Height;
this.Height = labelTitle.Height;
labelExpand.ImageIndex = 1;
}
else
{
this.Height = this.panelHeight;
labelExpand.ImageIndex = 0;
}
}
}
private void CollapsablePanel_Resize(object sender, System.EventArgs e)
{
labelExpand.Location = new Point(Width - labelExpand.Width, 0);
}
}
|
|
|
|
|
Thanks very much. I'll take a look when I get to work
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hi,
David directed me to this post, i have actually made a version of this, there is a screenshot here[^] as david said, there are a few problems to work out, but if you want the code, its yours.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
It looks great! The source would be much appreciated, thanks
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
http://www.onyeyiri.co.uk/ExplorerBarDemo.zip[^]
hope you like it, unsuprisingly, the controls code is in the file called ExplorerBar.cs, that download is a demo app, showing the current features of it.
NOTE: the errors are as follows, it does not like you switching Colour Schemes on-the-fly [doing this changes the look, but causes other problems], and in the XPTheme mode, it doesnt quite come out with the color of the current xptheme [i suggest using the colour scheme style]. i am wokring on both of these problems.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Thanks very much. Great stuff
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|