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
A

arnold_w

@arnold_w
About
Posts
363
Topics
111
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Application is "dead" when I open it in a browser
    A arnold_w

    My colleague, who is on vacation, wrote a Javascript application that I need to port to C#. I know nothing about Javascript so at this point I'm happy if I'm just able to execute it successfully. There is a file called "index.html" and when I open this in Chrome I can see buttons, textboxes, comboboxes, etc but everything is "dead" , nothing happens when I e.g. click a button. Does anybody know how I can bring the application to life? Also, does anybody know if there exist a free IDE where I can edit the source code (it would be a bonus if I can step the code as well)? Updated information: I installed "Visual Studio Code" and opened the project folder there and when I click "Start Debugging" I see the GUI flashing by quickly and then nothing happens. In the "Terminal" window I see the following: "npm run start Debugger attached. > firmwareprogrammer@1.0.0 start > electron . Debugger attached. Main process started Waiting for the debugger to disconnect... Waiting for the debugger to disconnect..." Updated information again: I'm now able to step the code in "Visual Studio Code" and when the following function is executed, the GUI-windows are showing (but they are all white), but as soon as the function is finished executing the GUI-windows disappear:

    function createWindow () {
    mainWin = new BrowserWindow({
    width: 1100,
    height: 870,
    minWidth: 1100,
    maxWidth: 1100,
    minHeight: 870,
    maxHeight: 870,
    webPreferences: {
    nodeIntegration: true,
    contextIsolation: false,
    enableRemoteModule: true,
    // preload: path.join(__dirname, "preload.js")
    }
    })

    // mainWin.removeMenu();
    // win.loadFile('index.html')
    //require("@electron/remote/main").enable(win.webContents);
    //mainWin.webContents.openDevTools()
    devtools = new BrowserWindow();
    mainWin.webContents.setDevToolsWebContents(devtools.webContents)
    mainWin.webContents.openDevTools({ mode: 'detach' })

    mainWin.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file',
    slashes: true
    }))
    mainWin.webContents.openDevTools()
    mainWin.on('close', () => {
    mainWin = null;
    })
    }

    JavaScript javascript csharp visual-studio html database

  • Why is my AlphaPanel approach to disable the entire GUI so slow?
    A arnold_w

    I don't disconnect anything, I just ask the Device Manager what Com ports are present and then I compare that with what was present before and take appropriate actions (e.g. remove or add Com port from a combobox). But this is not what's taking so long, it's the AlphaPanel handling that takes time.

    C# csharp winforms com performance question

  • Why is my AlphaPanel approach to disable the entire GUI so slow?
    A arnold_w

    I'm programming using WinForms in C# .NET 2.0 and sometimes I want to disable the entire GUI so that the user can't e.g. press any buttons or change any comboboxes. I found this through googling Disable form Controls Without Being Gray!!![^] and I thought it was working great, until today. Whenever USB-cables are connected/disconnected on my PC, I get an event and then I disable the GUI, using the code I linked to above, and re-enumerate my virtual COM-ports and then I enable the GUI again. I discovered that executing this.Controls.Add(alphapanel); takes almost 2 seconds and executing alphapanel.BringToFront(); takes another second! Is there anything I can do to speed this up?

    C# csharp winforms com performance question

  • Virtual USB Com port makes my C# control application freeze and crash when I single-step the microcontroller with the USB-device
    A arnold_w

    I have a C# control application that communicates via USB (it shows up as a Com port in the Device Manager, but the electrical interface is USB, not RS232) with a development board with a microcontroller from ST Microelectronics (the driver I use is automatically installed by Windows 10 or Windows 11). Sometimes I need to debug and single-step the microcontroller and when I do, the C# application freezes for a long time and then usually eventually crashes when the Com port finally disappears and my Com connection is lost. Is there anything I can do to handle this a little more gracefully? It would be great if the Com port connection could simply get disconnected (instead of freezing the application) and the Com port disappears and then it could try to reconnect every second, in case the single-stepping has stopped and the microcontroller is running normally again. I'm programming in .NET 2.0 and I communicate using the System.IO.Ports.SerialPort class.

    C# csharp com hardware debugging question

  • Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing?
    A arnold_w

    Yes, that was it!!! Thank you. The beginning of my comboBox_TextChanged method now looks like this:

        private void comboBox\_TextChanged(object sender, EventArgs e)
        {
            int selectedIndex = comboBox.SelectedIndex;  // When we edit the currently shown text, then comboBox.SelectedIndex becomes -1! 
            if (0 <= selectedIndex)
            {
                currentlySelectedIndex = selectedIndex;
            }
            bool enableItem = (selectedIndex < 0) ? false : items\[selectedIndex\].enabled;
            comboBox.ForeColor = enableItem ? Color.Black : Color.Gray;
    
    C# com graphics question

  • Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing?
    A arnold_w

    I added Debug.WriteLine(enableItem ? "Enabled" : "Disabled"); inside comboBox_DrawItem and it always prints "Disabled".

    C# com graphics question

  • Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing?
    A arnold_w

    I'm not sure I understand what you mean. Even if I do a global replace Color.Black -> Color.Gray then the selected item still has black color, not gray, when the dropdown list isn't shown.

    C# com graphics question

  • Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing?
    A arnold_w

    I work with many Com-ports and to make them easier to keep track of I've created a combobox that has a fixed prefix (the information from the Device Manager, e.g. "STMicroelectronics STLink Virtual COM Port (COM21)") and an editable suffix where I can type in e.g. "My Product A". The code works great, but now I would like to also be able to disable (make the text gray) items in my combobox and it works fine in the dropdown list, but as soon as I close the dropdown list and only the selected item is shown, then the text is always enabled (black, not gray). Does anybody know what I should correct in my code to get the desired behavior?

    partial class SemiEditableComboBox
    {
    /// /// Required designer variable.
    ///
    private System.ComponentModel.IContainer components = null;

    /// /// Clean up any resources being used.
    /// 
    /// true if managed resources should be disposed; otherwise, false.
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
    
    #region Component Designer generated code
    
    /// /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// 
    private void InitializeComponent()
    {
        this.comboBox = new System.Windows.Forms.ComboBox();
        this.SuspendLayout();
        //
        // comboBox
        //
        this.comboBox.FormattingEnabled = true;
        this.comboBox.Location = new System.Drawing.Point(0, 0);
        this.comboBox.Name = "comboBox";
        this.comboBox.Size = new System.Drawing.Size(454, 24);
        this.comboBox.TabIndex = 0;
        //
        // SemiEditableComboBox
        //
        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.Controls.Add(this.comboBox);
        this.Name = "SemiEditableComboBox";
        this.Size = new System.Drawing.Size(454, 24);
        this.ResumeLayout(false);
    
    }
    
    #endregion
    
    private System.Windows.Forms.ComboBox comboBox;
    

    }

    public delegate void DelegateItemAndString(object item, string newString);

    class SemiEditableComboBoxItem
    {
    public string lastString;
    public string fixedPrefix;
    publi

    C# com graphics question

  • To be deleted...
    A arnold_w

    Ooops, wrong forum section. Can a moderator please delete this thread (the Delete link is disabled for me)?

    C / C++ / MFC question

  • Proper way to put a C++ object inside a struct initialization?
    A arnold_w

    I'm not allowed to make changes inside the class, I'm only supposed to write code that uses that class.

    C / C++ / MFC hardware c++ question workspace

  • Proper way to put a C++ object inside a struct initialization?
    A arnold_w

    I edited my initial post to also show the actual class.

    C / C++ / MFC hardware c++ question workspace

  • Proper way to put a C++ object inside a struct initialization?
    A arnold_w

    I'm able to compile your code example. However, I just realized that I had forgotten the following line of code (I didn't think it was important) in my first post (I have added it now):

    MyObject(const MyObject&) = delete;

    I'm not good at programming C++ so I'm not sure what that line does. After I have added this line, I get the following error message with your code example: "use of deleted function 'MyNamespace::MyObject::MyObject(const MyNamespace::MyObject&)"

    C / C++ / MFC hardware c++ question workspace

  • Proper way to put a C++ object inside a struct initialization?
    A arnold_w

    I working in an embedded environment (STM32 microcontroller) and I compile using GCC (STM32CubeIDE). I want to put a C++ object inside a struct and this is the only way I could get it to compile:

    namespace MyNamespace {
    class MyObject
    {
    int m_i;
    public:
    MyObject(int i):m_i(i){}
    MyObject(const MyObject&) = delete;
    };
    }

    typedef struct {
    MyNamespace::MyObject* MyObject;
    } MyStruct_s;

    static MyStruct_s MyStruct = {new MyNamespace::MyObject(0) };

    However, I'm having strange hanging issues in my code and I suspect the code above might be the cause. Is the code above legal or will it corrupt RAM? If so, what's the correct way to do it? Ideally I'd like to have the whole object inside the struct, not just a pointer to it.

    C / C++ / MFC hardware c++ question workspace

  • Struct with union with different sized members - How can I declare the smallest struct?
    A arnold_w

    I am writing code in standard C for a microcontroller (STM32L) and I compile with GCC. I have a struct that contains a union and the union can be of different size:

    struct MyStruct
    {
    int someInteger;
    union
    {
    int smallMember[1];
    int bigMember[1000];
    } smallOrBigMember;
    };

    Is it possible for me to declare an object of MyStruct that only occipies 8 bytes of memory if I only intend to use the smallMember of that object?

    C / C++ / MFC question hardware performance

  • C# graph/diagram showing executing tasks vs time, that scales well with large data sets?
    A arnold_w

    I want to write a simple C# tool that shows what tasks in my embedded product are being executed at different times. You can see here for an example: https://i0.wp.com/microcontrollerslab.com/wp-content/uploads/2020/06/FreeRTOS-Preemptive-time-slicing-scheduling-algorithm-example.jpg[^]. The tool should be able to scroll up/down/left/right in the graph area by dragging the mouse while clicking a mouse button and zoom in/out easily with the mouse wheel. Is anybody aware of any open source code that can create this graphical representation that scales well with large data sets?

    C# csharp visual-studio com hardware algorithms

  • Advice on writing a GUI application that can run on very old Windows operating systems without Service Packs and Frameworks
    A arnold_w

    Some of my employer's customers have old Windows-computers (some are from the 90's) and they are not allowed to connect to the Internet and they have no Service Packs or Frameworks installed. I need to write a simple GUI application that does some UART-communication that can run on these old computers and I would greatly appreciate some advice. 1. What API would you recommend I use? I've heard of an API called "Win32", is that the one I should use? 2. What GUI library would you recommend I choose? 3. Can I program in C++ or am I restricted to C? 4. Is Visual Studio 2005 a good choice for an IDE or would you recommend something else? 5. Anything else I need to be aware of?

    C / C++ / MFC visual-studio csharp c++ json question

  • Check if .exe-file, WITH A PATH(!!!), is running, from within a bat-file?
    A arnold_w

    Thank you!

    Windows Development debugging help tutorial question announcement

  • Check if .exe-file, WITH A PATH(!!!), is running, from within a bat-file?
    A arnold_w

    Yes

    Windows Development debugging help tutorial question announcement

  • Check if .exe-file, WITH A PATH(!!!), is running, from within a bat-file?
    A arnold_w

    @echo off

    set "workdir=C:\MyProject\bin\release"
    set "workdir=%workdir:\=\\%"

    setlocal enableDelayedExpansion
    for /f "usebackq tokens=* delims=" %%a in (`
    wmic process where 'CommandLine like "%%!workdir!%%" and not CommandLine like "%%RuntimeBroker%%"' get CommandLine^,ProcessId /format:value
    `) do (
    for /f "tokens=* delims=" %%G in ("%%a") do (
    if "%%G" neq "" (
    rem echo %%G
    set "%%G"
    rem echo !ProcessId!
    goto :TheApplicationIsRunning
    )
    )
    )

    echo The application is not running
    exit /B

    :TheApplicationIsRunning
    echo The application is running
    exit /B

    Windows Development debugging help tutorial question announcement

  • Check if .exe-file, WITH A PATH(!!!), is running, from within a bat-file?
    A arnold_w

    Victor Nijegorodov wrote:

    BTW, what do you mean by "... from within a .bat-file."?

    I want to do it in bat-file language (the language you type in the command prompt C:\Windows\System32\cmd.exe)

    Windows Development debugging help tutorial question announcement
  • Login

  • Don't have an account? Register

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