How to implement "Spin Control" continuued

Chang Chi 21 Reputation points
2024-03-22T02:48:42.8+00:00

 

 Hi,

I like to press spin arrows to get “item No” show up on hStatic panel, and I get no response

Obviously, I am missing a key step in my dode.

I tried so many combinations of parameters with no success.

I included

    #include <commctrl.h>    

    to see if I can make use of

        typedef struct _NM_UPDOWN {

              NMHDR hdr;

              int   iPos;

              int   iDelta;

        } NMUPDOWN, * LPNMUPDOWN;

        LPNMUPDOWN lpnmud

 

        typedef struct tagNMHDR {

              HWND     hwndFrom;

              UINT_PTR idFrom;

              UINT     code;

        } NMHDR, *LPNMHDR;

 

I tried,

   LPNMUPDOWN lpnmud  = (LPNMUPDOWN)lParam;

   like some other people tries in the internet

 

I included the definition,

   #define WM_SPINCHANGE WM_APP + 0x42

 

Please, someone help me make this work for me

Thank you so very much in advance,

PS: In preveous issue I was late in responding to your answers. I still don't get any response.

I reissue the problem differently so don't miss the opportunity to get it it right 

ChangChiTheGtaphics

 

My codes are below,

 

#include <io.h>

#include <malloc.h>

#include <stdio.h>

#include <string.h>

#include <prevbmp.h>

#include <commctrl.h>

#define MAXBUFSIZE 32767 // must be at least 2048

#define MAXPATH 256

#define WM_SPINCHANGE WM_APP + 0x42

 

extern struct tagBMPHEADER BMPHEADER;  //,*pBMPHEADER;

extern int xscr,yscr,ctrwall,wallsel,wellnum,wallnummax,iCurrentColor,IsMakeFloor;  extern GLuint ovSel;

extern int msct[10],msctp[11],jobsel[5],ver[5], newPos;

extern HWND  ViewWindow,hC20;          /* View window */

extern HINSTANCE hInstance;

extern BOOL CALLBACK Ac11ALessTestProc(HWND, UINT, WPARAM, LPARAM);

extern HWND hAc11ALess, hAc11ALessTest, hAc4Less;

extern BOOL IsMakeMoreArea, bMoreSubArea,bRmDatReadIn,IsInstruct,bMgen;

 

 

int LayBit27Test(char* picture, int option)

{

       static HWND hStatic = NULL, hSpin = NULL;

       const char* aItems[] = {

             "Item 1",

             "Item 2",

             "Item 3",

             "Item 4",

       };

       int ii;

       static int iLow = 0, iHigh = _countof(aItems) - 1; 

 

       switch (msct[1]) {

       case 0:  msct[1] = 0;

             ii = 0;

       case 1:  msct[1] = 1;

             if (hAc11ALessTest == NULL) {

                    hAc11ALessTest = CreateDialog(hInstance, "Ac11ALessTest", ViewWindow, Ac11ALessTestProc);

                    break;

             }

             ii = newPos;

             msct[1] = 2;

             break;

       case 2:  msct[1] = 2;

             ii = newPos;

             return 0;

}

 

 

AC11ALESSTEST DIALOGEX 600, 2, 48, 67

STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION

CAPTION "    Sel Area"

FONT 13, "MS Sans Serif", 0, 0, 0x1

BEGIN

    LTEXT           "",IDC_STATIC10,1,8,43,15,WS_BORDER,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE

    CONTROL         "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ARROWKEYS | WS_TABSTOP,37,9,10,14

    PUSHBUTTON      "OK",IDOK,0,40,46,14

END

 

 

 

BOOL CALLBACK Ac11ALessTestProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) {

#define WM_SPINCHANGE WM_APP + 0x42

        static HWND hStatic = NULL, hSpin = NULL;

 

        ////LPNMHDR phdr;

        ////LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;

        //NMUPDOWN nmud = (NMUPDOWN)lParam;

 

 

        const char* aItems[] = {       

              "Item 0",

              "Item 1",

              "Item 2",

              "Item 3",

              "Item 4",

        };

        int ii;

        char buffer[100];

        static int i=0;

        static int iLow = 0, iHigh = _countof(aItems) - 1; 

 

    switch (iMsg)  //Ac11ALessTestProc

    {

        case WM_INITDIALOG:

        {

            //i++;

            hStatic = GetDlgItem(hDlg, IDC_STATIC10);

            hSpin = GetDlgItem(hDlg, IDC_SPIN2);

            //SendMessageA(hSpin, UDM_SETBUDDY, (WPARAM)hStatic, 0);

            SendMessageA(hSpin, UDM_SETRANGE, 0, MAKELPARAM(iHigh, iLow));

            SendMessageA(hSpin, UDM_SETPOS, 0, iLow);                     

            SendMessageA(hStatic, WM_SETTEXT, 0, (LPARAM)aItems[iLow]);

             //if (i >= 3)break;

            return (INT_PTR)TRUE;

        }

       case WM_COMMAND:

       {

             if (LOWORD(wParam) == IDOK) {

                    DestroyWindow(hDlg);

                    msct[1] = 2;

             }

       }

       break;

       case WM_SPINCHANGE:

      {

            int newPos = LOWORD(SendMessageA(hSpin, UDM_GETPOS, 0, 0));

                    /*

                    //newPos = newPos + nmud.iDelta;

                    //strcpy(buffer, lpnmud.iPos);

                    //////strcpy(buffer, lpnmud->iPos);

                    //LPNMUPDOWN, lpnmud

                    //strcat(buffer,lpnmud->iDelta);      

                    ////newPos = lpnmud->iPos + lpnmud->iDelta;

                    //buffer = lpnmud->iPos + lpnmud->iDelta;

                    //newPos = newPos+2;  

                    //i = lpnmud->iPos; // +lpnmud->iDelta;

                    //i = lpnmud.iPos + lpnmud.iDelta;

                    ii = lpnmud->iPos;

                    */          

 

                    //LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;

 

                    //newPos = lpnmud->iPos + lpnmud->iDelta;

            SendMessageA(hStatic, WM_SETTEXT, 0, (LPARAM) aItems[newPos]);

        }

        break;

 

        case WM_NOTIFY:

        {

            //LPNMUPDOWN lpnmud  = (LPNMUPDOWN)lParam;

            LPNMHDR phdr = (LPNMHDR)lParam;               

            if (phdr->code == UDN_DELTAPOS)

               PostMessageA(hDlg, WM_SPINCHANGE, 0, 0); // WM_NOTIFY received before spin control reflects new position

        }

        break;

 

        case WM_DESTROY:

            PostQuitMessage(0);

        break;

       }//switch (iMsg)

       //return (INT_PTR)FALSE;

       return FALSE;

}

 

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,637 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Chang Chi 21 Reputation points
    2024-04-04T23:25:54.56+00:00

    The question is withdrawn. Thank you

    0 comments No comments