dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Multicolumn list in WinApi

  1. #1
    Join Date
    Mar 2016
    Posts
    1

    Question Multicolumn list in WinApi

    How can I do a Multicolumn listbox, 3x10, where 3 are "song", "year", "artist", and 10 the amount of elements that sould be in the list?

    #include <windows.h>
    #include <CommDlg.h>
    #include "resource.h"
    #include <commctrl.h>
    #include <stdio.h>
    #include <winuser.h>

    using namespace std;

    HWND hDlg;
    HINSTANCE ghDlg;

    BOOL CALLBACK MsgDlgProc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg2Proc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg3Proc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg4Proc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg5Proc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg6Proc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK MsgDlg7Proc(HWND, UINT, WPARAM, LPARAM);

    BOOL CALLBACK MsgDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {

    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {

    switch (LOWORD(wParam)) {

    case IDC_BUTTON1: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG2), 0, MsgDlg2Proc);
    break;
    }

    case IDC_BUTTON2: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG3), 0, MsgDlg3Proc);
    break;
    }

    case IDC_BUTTON3: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG5), 0, MsgDlg5Proc);
    break;
    }

    case IDC_BUTTON4: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG6), 0, MsgDlg6Proc);

    break;
    }

    case IDC_BUTTON5: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG4), 0, MsgDlg4Proc);

    break;
    }

    }
    break;
    }
    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmdLine, int showCmd){

    hDlg = CreateDialog(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);

    ShowWindow(hDlg, showCmd);

    MSG msg;
    ZeroMemory(&msg, sizeof(MSG));

    while (GetMessage(&msg, 0, 0, 0)) {
    if (hDlg == 0 || !IsDialogMessage(hDlg, &msg)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }
    return (int)msg.wParam;
    }

    BOOL CALLBACK MsgDlg2Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {
    case IDC_BUTTON6: {
    break;
    }
    case IDC_Examinar1: {
    break;
    }
    case IDOK1: {
    break;
    }
    case IDCANCEL1: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
    break;
    }
    }
    }

    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    BOOL CALLBACK MsgDlg3Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {
    case IDC_Regresar1: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
    break;
    }
    }
    }

    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    BOOL CALLBACK MsgDlg4Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {

    case IDC_Regresar2: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
    break;
    }
    case IDC_Play1: {
    break;
    }
    case IDC_Stop1: {
    break;
    }
    case IDC_Pause1: {
    break;
    }
    case IDC_Rewind1: {
    break;
    }
    case IDC_Forward1: {
    break;
    }
    }
    }

    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    BOOL CALLBACK MsgDlg5Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {

    case IDOK2: {
    break;
    }
    case IDCANCEL2: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
    break;
    }
    }
    }

    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    BOOL CALLBACK MsgDlg6Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {

    case IDC_Regresar3: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
    break;
    }
    case IDC_Prov1: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG7), 0, MsgDlg7Proc);
    break;
    }
    }
    }
    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }

    BOOL CALLBACK MsgDlg7Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {

    case WM_INITDIALOG:
    return true;

    case WM_COMMAND: {
    switch (LOWORD(wParam)) {

    case IDC_Regresar5: {
    ShowWindow(hDlg, SW_HIDE);
    DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG6), 0, MsgDlg6Proc);
    break;
    }
    case IDC_Play2: {
    break;
    }
    case IDC_Stop2: {
    break;
    }
    case IDC_Pause2: {
    break;
    }
    case IDC_Rewind2: {
    break;
    }
    case IDC_Forward2: {
    break;
    }
    }
    }

    case WM_CLOSE:
    DestroyWindow(hDlg);
    return true;
    case WM_DESTROY:
    PostQuitMessage(0);
    return true;
    }
    return false;
    }




    Thanks!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,525

    Re: Multicolumn list in WinApi

    Do you mean the listbox control or the ListView control?
    Anyway, please, read this discussion...

    Besides, please, use CODE tags when posting code snippets!
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)