Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

mo1492

@mo1492
About
Posts
86
Topics
34
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What's up with displaying transparent pixel? Closed
    M mo1492

    Still don't know why this happens but it doesn't matter. I found that setting my control to DoubleBuffered = true, the display time goes to 0. Sorry for the post. Can some tell me why displaying the transparent pixel takes so much time? See bottom of sample for time comparison. public class CellColor { public Rectangle Rect; public Color Color; public CellColor(Rectangle rect, Color clr) { Rect = rect; Color = clr; } } // At form load time, this array is loaded with pixel data from a 32 x 32 Icon. // About half of the pixels in the sample icon are transparent (A=0,R=255,G=255,B=255). private CellColor[,]? _CellBounds; protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); DrawCells(e.Graphics); } private void DrawCells(Graphics gr) { int iWd = this._CellBounds!.GetUpperBound(0) + 1; int iHt = this._CellBounds.GetUpperBound(1) + 1; Stopwatch sw = new(); sw.Start(); for (int iRow = 0; iRow < iHt; iRow++) { for (int iCol = 0; iCol < iWd; iCol++) { CellColor cc = this._CellBounds[iRow, iCol]; using(SolidBrush br = new(cc.Color)) { gr.FillRectangle(br, cc.Rect); } } } sw.Stop(); // Displaying the data without pixel modification takes about 60 milliseconds. // When loading _CellBounds, if I replace the transparent pixel with a real color like Color.White, // this loop takes 4 milliseconds. DebugClass.WriteLine(string.Format("{0}", sw.ElapsedMilliseconds)); }

    C# dotnet graphics data-structures question

  • ControlDesigner issue
    M mo1492

    I'm sorry for the confusion. There are 2 files to a UserControl when created from the application: In this case UserControl1.cs UserControl1.Designer.cs The latter file contains the standard Dispose() code which I did not supply since it's just standard code. For arguments sake, I started with the code you referenced 'as is'.. That means I copied and pasted the whole sample into a project file, built it, and tried it by loading it into a from from the toolbox; it did not function as described... 1. When the mouse moves into the control, the control does not show the highlight the border as the MouseEnter() method should do. 2. The property that is added in the designer "OutlineColor" does not show in the grid properties. I've managed to get the debugger to work in DesignMode and set a break points in the MouseEnter() method and the OutLineColor.Set property and the OnPaintAdornments() method. None of the break points are hit when the control is loaded into the form. thanks

    C# help question csharp design tutorial

  • ControlDesigner issue
    M mo1492

    Yes this is the example where a copied the test code from. I tried this example 'as is' but it did not work. The code in my question is the same; It just uses a UserControl1 that I created in my test project while debugging. I did not include the UserControl1.Designer.cs code which includes the other code. Thank you

    C# help question csharp design tutorial

  • ControlDesigner issue
    M mo1492

    Not sure if this is the correct group for this question but I am working with C#. I'm migrating from VS2005 to VS2022 and having problem with ControlDesigner in my Control. It seems that the ControlDesigner is not functioning. I'm not too familiar with ControlDesigner programming so after working on this for a while I decided to start from scratch. I found an example in Microsoft Help Viewer for ControlDesigner. I copied and pasted the example code into a project UserControl1 and it too does not seem to function. When moving the mouse over the control the outline does not highlight and also the OutlineColor property is not shown in the Properties window. Can someone help? Below is the sample code from Help Viewer. The only difference the test control is called UserControl1 Thank you.

    using System.ComponentModel;

    namespace TestApp
    {
    // ExampleControlDesigner is an example control designer that
    // demonstrates basic functions of a ControlDesigner.
    public class ExampleControlDesigner : System.Windows.Forms.Design.ControlDesigner
    {
    // This Boolean state reflects whether the mouse is over the control.
    private bool mouseover = false;
    // This color is a private field for the OutlineColor property.
    private Color lineColor = Color.White;

        // This color is used to outline the control when the mouse is 
        // over the control.
        public Color OutlineColor
        {
            get
            {
                return lineColor;
            }
            set
            {
                lineColor = value;
            }
        }
    
        public ExampleControlDesigner()
        {
        }
    
        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.
        protected override void OnMouseEnter()
        {
            this.mouseover = true;
            this.Control.Refresh();
        }
    
        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.        
        protected override void OnMouseLeave()
        {
            this.mouseover = false;
            this.Control.Refresh();
        }
    
        // Draws an outline around the control when the mouse is 
        // over the control.    
        protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
        {
            if (this.mouseover)
            {
                pe.Grap
    
    C# help question csharp design tutorial

  • Can you use sqlite in vs2022? CLOSED
    M mo1492

    I Knew if I asked the question I would get it to work. I tried a different nuget package, specifically System.Data.SQLite and now it works. Sorry for the bogus post. I've just upgraded to VS2022 from VS2005 so I am sort of lost. I've tried several methods from suggestions on the internet and still have not been able to add a reference to sqlite in my test project. When I try to manually add the sqlite3.dll I get a message saying the dll is immutable. Articles on the internet seem to suggest you can use it but I can't find a way to add a reference. Can someony help? Thanks

    C# sqlite question visual-studio functional help

  • Problem capturing last group in a line: CLOSED
    M mo1492

    Thank you for your help :)

    Regular Expressions help regex question

  • Problem capturing last group in a line: CLOSED
    M mo1492

    Don't know if this is the correct solution but it seems to work. Using the RegexOptions.RightToLeft option seems to work. I'm not too familiar with Regex. I've created an expression to capture data in a line and it works except for the last group DataType which does not extract the value "dtText". Can someone help? Thank You Expression: FieldName=(?.*?),ColumnWidth=(?.*?),Size=(?.*?),DataType=(?.*?) Data: FieldName=Field1,ColumnWidth=50,Size=10,DataType=dtText Output: FieldName: [Field1] ColumnWidth: [50] Size: [10] DataType []

    Regular Expressions help regex question

  • Problem when setting the ReadOnly state of a property: CLOSED
    M mo1492

    Aaaaaaaaaaaaaaaaaarg! As usual once I post I figure it out. The PropertyGrid does not maintain the state. It has to be reloaded. How Dumb. Sorry Hello all, I have a problem where the PropertyGrid does not update a property when changing a property to ReadOnly and not ReadOnly. The problem occurs when I have 2 controls of the 'same type'. Below is test code which contains all of the things I have tried to refresh the PropertyGrid with no success. When Control1 is loaded into the PropertyGrid I change the DesignLocked state and update the ReadOnly state of the PostPrintString to Readonly or not ReadOnly depending on the DesignLocked Value. This works in Control1. However, after I have changed the value in Control1 and then select Control2 into the PropertyGrid (through a button click in MainForm), the PostPrintString property in the grid maintains the same ReadOnly state of Control1. I've tried a number of things I've seen on google including NotifyParentPropertyAttribute with no success. I would appreciate any help with this. Thank you This is the test code in MainForm to load each control. Private Sub Ctrl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctrl1.Click Me.PropertyGrid1.SelectedObject = Nothing Me.PropertyGrid1.Refresh() Me.PropertyGrid1.SelectedObject = Me.ctrl1 Me.PropertyGrid1.Refresh() End Sub Private Sub Ctrl2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctrl2.Click Me.PropertyGrid1.SelectedObject = Nothing Me.PropertyGrid1.Refresh() Me.PropertyGrid1.SelectedObject = Me.ctrl2 Me.PropertyGrid1.Refresh() End Sub Below is the test code in a UserControl that shows what I do when I change the DesignLocked property. Imports System.ComponentModel Imports System.Reflection Public Class TestUserControl ' Gets loaded with MainForms PropertyGrid Public _PropertyGrid As PropertyGrid _ Public Property PostPrintString() As String Get Return "" End Get Set(ByVal value As String) End Set End Property ''' ''' Get

    Visual Basic help css announcement

  • WritePrinter Fails to Print on Inkjet Printer
    M mo1492

    I found some old code that I wrote some time ago but never tested. I did a quick test with it and found that when I printed to my hp laserjet that I was only getting 1/2 of the data. After a little investigating I found that i didn't adjust for unicode data so using "RAW" mode passing 2 * datasize to WritePrinter((void*)data, 2*datasize, &dwBytesWritten) seem to fix the problem. However, as I said, this code is not fully tested so don't know if this is a real fix or if it has anything to do with your problem. I have problem using "TEXT" mode also but don't feel like investigating. The documentation just says "size of the array". Doesn't mention anything about unicode. Test data _T("abcd") Sending a size of 4 resulted in "ab" printing out. Sending a size of 8 resulted in "abcd" printing out. Also, if your printer data escape sequence as nul values in it, you may have to adjust it for unicode; ie. double nul. _T("escN") + nul + nul Best regards.

    C / C++ / MFC help csharp visual-studio question

  • WritePrinter Fails to Print on Inkjet Printer
    M mo1492

    Just a suggestion if you get really desperate; If the printer has a hex dump mode feature you can enable it and print out exactly what's being sent to the printer. Another way is to set the printer driver to 'Print to File' and your job will print to a file. Then if you are familiar with the printer language, you can examine the data to see if something has been added or missing in the printer data stream. Good luck

    C / C++ / MFC help csharp visual-studio question

  • Create an assignment operator that accepts as const value: CLOSED
    M mo1492

    Sorry, this always seems to happen after I post but I think I get it now. I'm trying to assign a value to a class. It compiles if i do this: Private Sub ab(Optional ByVal val As EncryptKey = Nothing) end Sub I was confused by this: Private Sub ab(Optional ByVal val As String = "") end Sub I don't know how String is defined to be able to accept this but what I'm doing won't work. Sorry again for the ugly post. Sorry about the subject line; didn't know how to describe my problem. Through searching around the internet i've come up with this class to be able to process a string value. Class EncryptKey Private _string As String = String.Empty Public Sub New(ByVal value As String) ' Remove white space Me._string = value.Trim() End Sub Public Shared Widening Operator CType(ByVal value As String) As EncryptKey Return New EncryptKey(value) End Operator Public Overrides Function ToString() As String Return _string End Function Public Function Length() As Integer Return Me._string.Length End Function Public Function IsEmpty() As Boolean Return (_string.Length = 0) End Function Public Shared Operator +(ByVal s1 As EncryptKey, ByVal s2 As EncryptKey) As EncryptKey ' Concat and remove white space Dim temp As String = (s1._string + s2._string).Trim() Return New EncryptKey(temp) End Operator End Class The class is working except for this case: Private Sub ab(Optional ByVal val As EncryptKey = "") ' Results in this error for the Optional assigment: 'error BC30060: Conversion from 'String' to 'EncryptKey' cannot occur in a constant expression. End Sub Is there a way to make the class able to accept this assignment as an Optional parameter? Thank you

    Visual Basic help algorithms tutorial question

  • Fuzzy Icons
    M mo1492

    Without seeing any code I don't know if this will help. I fixed this problem in VB by converting the icon to a bitmap with the routine below. I also use ExtractIconEx. I found that icon.ToBitmap() loses resolution for some reason. Sorry, you'll have to convert to C#. ''' ''' Convert Icon to Bitmap with resizing. ''' ''' ''' ''' ''' Public Shared Function IconToBitmap(ByVal ic As Icon, ByVal sz As Size) As Bitmap If ic Is Nothing Then Return Nothing Dim sourceWidth As Integer = ic.Width Dim sourceHeight As Integer = ic.Height Dim dPercent As Double = 0 Dim dPercentW As Double = 0 Dim dPercentH As Double = 0 dPercentW = (sz.Width / sourceWidth) dPercentH = (sz.Height / sourceHeight) If (dPercentH < dPercentW) Then dPercent = dPercentH Else dPercent = dPercentW End If Dim destWidth As Integer = (sourceWidth * dPercent) Dim destHeight As Integer = (sourceHeight * dPercent) Dim bm As Bitmap = New Bitmap(destWidth, destHeight, PixelFormat.Format32bppArgb) bm.SetResolution(destWidth, destHeight) Dim g As Graphics = Graphics.FromImage(bm) 'g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic ' This gives the best quality g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor g.DrawIcon(ic, New Rectangle(0, 0, destWidth, destHeight)) g.Dispose() Return bm End Function

    C# question

  • Creating custom BorderlessForm
    M mo1492

    I'm trying to create a CustomBorderlessForm and paint myself. I've gotten the basic functionality to work but have this issue. I have derived a TestForm from the custom BorderlessForm and when dropping a menustrip or toolstrip onto the TestForm, these controls dock at the top of the form overlaying the title area which I draw myself. I have tried a number of solutions with no success and now I am just trying to do the simplest thing I can think of. I have created a property on the BorderlessForm to Enable or Disable showing a MenuStrip. When Enabled on the derived TestForm, I create a MenuStrip and place it on the TesForm at a specific location. This works but I cannot edit the MenuStrip from the Designer. Below is code for a custom ParentControlDesigner in which I am trying to EnableDesignMode to allow editing of the MenuStrip. However it still does not work. I have tried debugging into BorderlessFormDesigner below but the Designer does not hit the break point within Initialize(). To do this I have setup the project in MyProject to execute a new instance of VS and load the project. Within the new instance of VS I open the TestForm in the Designer but the Designer does not hit the break point. I've tried setting a break point in both the first and second instance. I've done this sort of thing before with other projects with success. I'm guessing maybe these controls to not support this type of functionality. If this is possible I would appreciate some advice. Thank you. Here is the code excluding the BorderlessForm.Designer.vb code.

    Imports System.ComponentModel
    Imports System.ComponentModel.Design
    Imports System.Runtime.CompilerServices
    Imports System.Windows.Forms.Design
    Imports System.Windows.Forms.Design.Behavior
    _
    _
    Public Class BorderlessForm
    ', GetType(ParentControlDesigner))> _

    Const ConstGridBorderlessTitle As String = "BorderlessForm"
    
    ' The MenuStrip object and access for the Designer
    Private \_MenuStrip As MenuStrip
    \_
    Public ReadOnly Property MenuStrip1() As MenuStrip
        Get
            Return Me.\_MenuStrip
        End Get
    End Property
    
    ' The property to enable showing a MenuStrip
    
    Visual Basic visual-studio design help workspace

  • How to determine specific object from Msg.HWnd 'MESSAGE CLOSED'
    M mo1492

    I think I found the answer by walking the Parent of Msg.HWnd until I find the containing 'Control' window in which FromHandle(hwnd) returns a Control object. In a custom control I have implemented an IMessageFilter to process the WM_MOUSEMOVE message to determine when the mouse is over a particular control. I then try to convert the hWnd to a control with Control.FromHandle(Msg.HWnd). This works for common controls. When the mouse is over as WebBrowser control I get Nothing returned from FromHandle(). I can use api GetClassName() to get the class name which returns either "shell embedding" or "internet explorer_server". The problem is I have more than one WebBrowser instance in the app. and need to distinguish between them. My question is, is there some value I can retrieve using an api with Msg.HWnd that will be unique to the particular instance object? WebBrowser does not have a Text property so GetWindowText() returns "". WebBrowser does have a Tag and Name property but I don't know if that is accessable through a windows api. Thank you

    Visual Basic question linux json help tutorial

  • How to perform non-case search in DataGridViewComboBoxColumn
    M mo1492

    Actually that's basically my hack except that the dataArray comes from my own xml class that loads the xmlfile data into variables (ie an array). The xml class formats the data and my custom DataGridView class loads from the xml class in the way you suggest. Thanks for you suggestion. :)

    Visual Basic help testing beta-testing regex xml

  • How to perform non-case search in DataGridViewComboBoxColumn
    M mo1492

    Sorry for the confusion. The error from my post in more clear terms are: Private Sub DataGridView1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles MyBase.DataError { ' DataGridViewDataErrorContexts.Display ' DataGridViewDataErrorContexts.Formatting Debug.WriteLine(e.Context.ToString()) } My ComboBox code would not do you any good because it is full of structure data references which would not make sense to you but here is what causes the problem, hopefully more clear. When I initialize the DataGridView columns, for the combobox object I load the list value which is the filename of the source xml file which happens to be "Foodlion" (note case). Dim cmb As New DataGridViewComboBoxColumn() cmb.Items.Add("Foodlion") I then create a row with the value for the ComboBox which happens to be "FoodLion" (case difference) because that's the way it was originally created in the xml file. Me.Rows.Add(dataArray()) This causes the above error whenever the cell is Formatted by the DataGridView. Making sure the data and the combobox list item are the same case fixes the problem. So something in the DataGridView formatting doesn't like the case difference. Therefore that's why I 'assumed' that the ComboBox or underlying code was doing a case sensitive search; My Bad. Your Q. Why not load the combobox using either the .ToLower() or .ToUpper() functions? When the xml file is created the filename is saved in the xml data (in a particular case). The 'case' of the filename of the file that is stored on disk can change. When I enumerate the xml files on disk (Directory.GetFiles(path, "*.xml")), I use that filename to load into the combobox list as above (cmb.Items.Add("Foodlion"). If its' case is not the same as what is stored in the xml file, I get the DataError. I just asked the question in case someone may have encountered this type of issue with DataGridViewComboBoxColumn. I think I have found a work around 'HACK' by saving the filename in the xml file in a particular format and then formatting the filename from disk the same way. I hate to HACK code. Again, sorry for the confusion. :( Hope this is clearer. Thanks :)

    Visual Basic help testing beta-testing regex xml

  • How to perform non-case search in DataGridViewComboBoxColumn
    M mo1492

    Hello, I have added a DataGridViewComboBoxColumn to a DataGridView and i'm having a little problem. For testing I am loading one item in the combobox. The item value source is an xml filename without path or extension; ie. "Foodlion". The xml file has an entry that defines this filename but has a different case like "FoodLion". After loading the xml file and passing its' value "FoodLion" to the combobox, I get this context error in DataGridView1.DataError: Formatting, Display I'm not performing any formatting on this field since I expect just text. I get it that the combobox must be performing a FindExact() type search and does not match. Before I go through the pain staking effort to try an make sure the names match, is there something I can do change the combobox processing? Thanks

    Visual Basic help testing beta-testing regex xml

  • VS2008 entropy - cannot open project resource views RC1015 error
    M mo1492

    Lastly, you probably have done this already but a search on "winresrc.h resource RC1015" brings up a number of questions and responses concerning this error. Good luck :)

    C / C++ / MFC visual-studio help csharp com graphics

  • VS2008 entropy - cannot open project resource views RC1015 error
    M mo1492

    winresrc.h is in the Platform SDK folder on my system. Is this path included in your projects Include Directories list or has it maybe been moved into the incorrect order in the list?

    C / C++ / MFC visual-studio help csharp com graphics

  • VS2008 entropy - cannot open project resource views RC1015 error
    M mo1492

    I'll just throw this out there from my own experience. You might try creating a 'test' user profile to see if it fixes it. I had a problem with VS2005 a couple of years ago that I could not figure out. I looked and looked and even tried reinstalling VS and couldn't fix it. I have two user profiles on my system and just by chance I logged onto my admin profile and opened VS and the problem was not there. So I created a new user profile that corrected the problem. Have no idea why.

    C / C++ / MFC visual-studio help csharp com graphics
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups