Click here to Skip to main content
15,847,653 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralArrrgh Win32! Pin
honey the codewitch21-Sep-23 6:47
mvahoney the codewitch21-Sep-23 6:47 
GeneralRe: Arrrgh Win32! Pin
Andreas Mertens21-Sep-23 8:37
professionalAndreas Mertens21-Sep-23 8:37 
GeneralRe: Arrrgh Win32! Pin
David O'Neil21-Sep-23 9:29
professionalDavid O'Neil21-Sep-23 9:29 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch21-Sep-23 13:21
mvahoney the codewitch21-Sep-23 13:21 
GeneralRe: Arrrgh Win32! Pin
Rick York21-Sep-23 14:10
mveRick York21-Sep-23 14:10 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch21-Sep-23 14:12
mvahoney the codewitch21-Sep-23 14:12 
GeneralRe: Arrrgh Win32! Pin
David O'Neil21-Sep-23 16:07
professionalDavid O'Neil21-Sep-23 16:07 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch21-Sep-23 16:10
mvahoney the codewitch21-Sep-23 16:10 
Here's what I do - because I only need to do this for dynamic menus:

Of note is this: mif.wID = (~i); which yields a negative ID I can reconstitute into a gpio id by repeating the ~ operator on it.

C++
static void update_gpios() {
    updating_gpios = true;
    while(GetMenuItemCount(gpio_menu)) {
        RemoveMenu(gpio_menu,0,MF_BYPOSITION); 
    }
    wchar_t name[256];
    for(size_t i = 0; i < 256; ++i) {
        gpio_t& g = gpios[i];
        if(g.mode!=0) {
            wcscpy(name,L"GPIO ");
            _itow((int)i,name+wcslen(name),10);
            switch(g.mode) {
                case INPUT:
                case INPUT_PULLDOWN:
                case INPUT_PULLUP:
                    wcscat(name,L" <");
                    break;
                case OUTPUT:
                case OUTPUT_OPEN_DRAIN:
                    wcscat(name,L" >");
            }
            MENUITEMINFOW mif;
            mif.cbSize = sizeof(MENUITEMINFOW);
            mif.cch = wcslen(name);
            mif.dwTypeData = name;
            mif.fMask = MIIM_STRING | MIIM_ID | MIIM_STATE;
            mif.wID = (~i);
            mif.fState = g.value==0?MFS_UNCHECKED:MFS_CHECKED;
            InsertMenuItemW(gpio_menu,GetMenuItemCount(gpio_menu),TRUE,&mif);
        }
        if(g.hwnd_text!=NULL) {
                // update the visible text box
                wchar_t val[64];
                if(!g.is_input()) {
                if(g.value==HIGH) {
                    wcscpy(val,L"HIGH");
                } else if(g.value==LOW) {
                    wcscpy(val,L"LOW");
                } else {
                    _itow(g.value,val,10);
                }
                if(GetFocus()!=g.hwnd_text) {
                    SetWindowTextW(g.hwnd_text, val);
                }
            }
            EnableWindow(g.hwnd_text,g.is_input()?TRUE:FALSE);
        }
    }
    updating_gpios = false;   
}

Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralRe: Arrrgh Win32! Pin
David O'Neil21-Sep-23 16:21
professionalDavid O'Neil21-Sep-23 16:21 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch21-Sep-23 16:23
mvahoney the codewitch21-Sep-23 16:23 
GeneralRe: Arrrgh Win32! Pin
David O'Neil21-Sep-23 16:09
professionalDavid O'Neil21-Sep-23 16:09 
GeneralRe: Arrrgh Win32! Pin
Kornfeld Eliyahu Peter21-Sep-23 20:12
professionalKornfeld Eliyahu Peter21-Sep-23 20:12 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch22-Sep-23 2:02
mvahoney the codewitch22-Sep-23 2:02 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch22-Sep-23 3:32
mvahoney the codewitch22-Sep-23 3:32 
AnswerRe: Arrrgh Win32! Pin
enhzflep23-Sep-23 19:59
enhzflep23-Sep-23 19:59 
GeneralRe: Arrrgh Win32! Pin
honey the codewitch24-Sep-23 2:09
mvahoney the codewitch24-Sep-23 2:09 
Generalcannot use MS Teams any more - what can I do? Pin
DGrothe-PhD21-Sep-23 6:46
DGrothe-PhD21-Sep-23 6:46 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
k505421-Sep-23 7:22
mvek505421-Sep-23 7:22 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
Gerry Schmitz21-Sep-23 7:34
mveGerry Schmitz21-Sep-23 7:34 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
Al Fargnoli21-Sep-23 8:56
Al Fargnoli21-Sep-23 8:56 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
dandy7221-Sep-23 11:19
dandy7221-Sep-23 11:19 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
DGrothe-PhD22-Sep-23 4:10
DGrothe-PhD22-Sep-23 4:10 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
Sander Rossel21-Sep-23 22:46
professionalSander Rossel21-Sep-23 22:46 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
DGrothe-PhD22-Sep-23 4:27
DGrothe-PhD22-Sep-23 4:27 
GeneralRe: cannot use MS Teams any more - what can I do? Pin
obermd22-Sep-23 4:57
obermd22-Sep-23 4:57 

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.