qtwinapibuttonbuttonclickback-button-control

Next and previous control button in winAPI to go to next page (c++)


I am creating an winAPI application in c++ I have a photo in preview pane and I want to create two buttons NEXT and PREVIOUS on clicking them I will go to the next page .

Could you please give me the idea how to do that in c++ ??

Do I need to use QT libraray or it can be done using the in built function of WinAPI like -

HWND hwndButton1 = CreateWindow(L"BUTTON",L"NEXT",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,550,800,100,30,m_hwndPreview,(HMENU)buttonid1,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);

    HWND hwndButton2 = CreateWindow(L"BUTTON",L"PREVIOUS",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,650,800,100,30,m_hwndPreview,(HMENU)buttonid2,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);

and then using WM_COMMAND for both the button clicks.

Am I going right?

I just want my API application work like a .pdf extension file...as in PDF files we have up and down arrow and on clicking upon them we can go to the next page..In winAPIc++ I couldn't find any such arrow function.. please tell me if there is any such arrow up/down function present to go to next page (because I am very less interested in creating NEXT and PREVIOUS button using createwindow function.. It looks odd).


Solution

  • You have not mentioned what tools you are using, so we don't know if you have a resouce editor. You should research that in a forum appropriate for the tools. If you think writing one line of code to create a button is "very complicated" then you need a better tool.

    If you do not want the buttons to appear on top of the picture then you need another place to put them. One common possibility is a toolbar. It is a strip for buttons along the top or bottom of the main window:

    http://msdn.microsoft.com/en-us/library/windows/desktop/bb760435(v=vs.85).aspx

    With a resource editor you can draw an arrow on the button. Without a resource editor you can set the button text to a unicode arrow:

    SetWindowText(hwndButton1, L"\x25bc"); // down arrow, use 25b2 for up arrow