Click here to Skip to main content
15,914,488 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get Text control value into a numeric data type? [modified] Pin
Shy Agam30-Jul-06 6:44
Shy Agam30-Jul-06 6:44 
GeneralRe: How to get Text control value into a numeric data type? Pin
User 665830-Jul-06 8:27
User 665830-Jul-06 8:27 
GeneralMy dear friends.... Thanks both of you Pin
Amol Ravatale30-Jul-06 21:14
Amol Ravatale30-Jul-06 21:14 
QuestionHow to generate combo box in a datagrid in windows forms( .Net 1.1) Pin
Rocky#30-Jul-06 0:52
Rocky#30-Jul-06 0:52 
QuestionPLEASE HELP !!!!!!!!!! Pin
RoyiNamir30-Jul-06 0:12
RoyiNamir30-Jul-06 0:12 
AnswerRe: PLEASE HELP !!!!!!!!!! Pin
Christian Graus30-Jul-06 11:59
protectorChristian Graus30-Jul-06 11:59 
AnswerRe: PLEASE HELP !!!!!!!!!! Pin
Rob Graham30-Jul-06 15:57
Rob Graham30-Jul-06 15:57 
QuestionStack overflow in System.Drawing.dll... Pin
Shy Agam29-Jul-06 22:50
Shy Agam29-Jul-06 22:50 
Hey all,

I'm writing a class named ShapedForm.
It inherits from System.Windows.Forms.Form.
What I'm trying to accomplish is a built in functionality to make a non-rectangular form (i.e. a shaped form), and other functionalities such as form dragging with no title-bar.

I wrote this function:
public void ShapeTheForm(Bitmap ShapeImage, Color Key)
{
    if (busy) return;

    busy = true;
    // Instantiate a region to keep the transperant parts of the bitmap
    Region trans = new Region();
    // A region is set to infinate by default, and we want an empty region in order to add the pixels to it
    trans.MakeEmpty();

    int width = ShapeImage.Width;
    int height = ShapeImage.Height;

    for (int y = 0; y < height; ++y)
        for (int x = 0; x < width; ++x)
        {
            // Note: Comparison is not made between two Color objects on purpose.
            //       If a known color was set as the key (e.g. Fuchsia, Magenta...) the key name would be the known color,
            //       but the color returned by GetPixel() would have a hexed name, and the two would mistakenly not be equal.
            Color pixel = ShapeImage.GetPixel(x, y);
            // If the current pixel is supposed to be transparent...
            if (pixel.R == Key.R && pixel.G == Key.G && pixel.B == Key.B)
                // ... add the pixel to the transparent region
                trans.Union(new Rectangle(x, y, 1, 1));
        }

    // Initialize a temp region the size of the image
    Region tempRegion = new Region(new Rectangle(0, 0, ShapeImage.Width, ShapeImage.Height));
    // Exclude the transparent region from the full region
    tempRegion.Exclude(trans);
    // Remember the current border style
    lastStyle = FormBorderStyle;
    // Set to shaped layout
    if (InvokeRequired)
        Invoke(new LayoutSetDelegate(SetShapedLayout), ShapeImage, tempRegion);
    else
    {
        // Remove the form's border
        FormBorderStyle = FormBorderStyle.None;
        // Set the size of the form to the size of the image
        Size = new Size(ShapeImage.Width, ShapeImage.Height);
        // Set the form's region to the temp region
        Region = tempRegion;
        // Set the background of the form to the image
        BackgroundImage = ShapeImage;
    }

    // Release resources
    trans.Dispose();
    trans = null;

    busy = false;
}
It worked earlier, and I can't see the problem now.
When I call the function, the debugger lands on this line:
Region = tempRegion;

I get a StackOverflowException in System.Drawing.dll...

Do you see any problem with my code?
Any ideas why assigning the region fails?

Thanks in advance,
Shy.
AnswerRe: Stack overflow in System.Drawing.dll... Pin
mav.northwind30-Jul-06 3:23
mav.northwind30-Jul-06 3:23 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam30-Jul-06 5:09
Shy Agam30-Jul-06 5:09 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
leppie30-Jul-06 5:33
leppie30-Jul-06 5:33 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam30-Jul-06 5:48
Shy Agam30-Jul-06 5:48 
AnswerRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam30-Jul-06 6:08
Shy Agam30-Jul-06 6:08 
AnswerRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam1-Aug-06 6:05
Shy Agam1-Aug-06 6:05 
QuestionHow to do notepad with C# ? Pin
nguyenquang028429-Jul-06 22:36
nguyenquang028429-Jul-06 22:36 
AnswerRe: How to do notepad with C# ? Pin
Christian Graus29-Jul-06 22:59
protectorChristian Graus29-Jul-06 22:59 
QuestionRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:41
nguyenquang028430-Jul-06 2:41 
AnswerRe: How to do notepad with C# ? Pin
Christian Graus30-Jul-06 11:21
protectorChristian Graus30-Jul-06 11:21 
AnswerRe: How to do notepad with C# ? Pin
Colin Angus Mackay29-Jul-06 23:04
Colin Angus Mackay29-Jul-06 23:04 
QuestionRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:40
nguyenquang028430-Jul-06 2:40 
AnswerRe: How to do notepad with C# ? Pin
Colin Angus Mackay30-Jul-06 2:52
Colin Angus Mackay30-Jul-06 2:52 
AnswerRe: How to do notepad with C# ? Pin
Shy Agam29-Jul-06 23:06
Shy Agam29-Jul-06 23:06 
GeneralRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:37
nguyenquang028430-Jul-06 2:37 
QuestionRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:45
nguyenquang028430-Jul-06 2:45 
AnswerRe: How to do notepad with C# ? Pin
Shy Agam30-Jul-06 5:46
Shy Agam30-Jul-06 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.