void MessReadMountedSoftware(int drvindex) { // First read stuff into device view DevView_Refresh(GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW)); // Now read stuff into picker MessRefreshPicker(); }
static LRESULT CALLBACK DevView_WndProc(HWND hwndDevView, UINT nMessage, WPARAM wParam, LPARAM lParam) { struct DevViewInfo *pDevViewInfo; struct DevViewEntry *pEnt; int nStaticPos, nStaticWidth, nEditPos, nEditWidth, nButtonPos, nButtonWidth; RECT r; LONG_PTR l; LRESULT rc = 0; BOOL bHandled = FALSE; HWND hwndButton; switch(nMessage) { case WM_DESTROY: DevView_Free(hwndDevView); break; case WM_SHOWWINDOW: if (wParam) { pDevViewInfo = GetDevViewInfo(hwndDevView); DevView_Refresh(hwndDevView); } break; case WM_COMMAND: switch(HIWORD(wParam)) { case BN_CLICKED: hwndButton = (HWND) lParam; l = GetWindowLongPtr(hwndButton, GWLP_USERDATA); pEnt = (struct DevViewEntry *) l; DevView_ButtonClick(hwndDevView, pEnt, hwndButton); break; } break; } if (!bHandled) rc = DefWindowProc(hwndDevView, nMessage, wParam, lParam); switch(nMessage) { case WM_CREATE: if (!DevView_Setup(hwndDevView)) return -1; break; case WM_MOVE: case WM_SIZE: pDevViewInfo = GetDevViewInfo(hwndDevView); pEnt = pDevViewInfo->pEntries; if (pEnt) { DevView_GetColumns(hwndDevView, &nStaticPos, &nStaticWidth, &nEditPos, &nEditWidth, &nButtonPos, &nButtonWidth); while(pEnt->dev) { GetClientRect(pEnt->hwndStatic, &r); MapWindowPoints(pEnt->hwndStatic, hwndDevView, ((POINT *) &r), 2); MoveWindow(pEnt->hwndStatic, nStaticPos, r.top, nStaticWidth, r.bottom - r.top, FALSE); MoveWindow(pEnt->hwndEdit, nEditPos, r.top, nEditWidth, r.bottom - r.top, FALSE); MoveWindow(pEnt->hwndBrowseButton, nButtonPos, r.top, nButtonWidth, r.bottom - r.top, FALSE); pEnt++; } } break; } return rc; }
BOOL DevView_SetDriver(HWND hwndDevView, const software_config *config) { struct DevViewInfo *pDevViewInfo; const device_image_interface *dev = NULL; struct DevViewEntry *pEnt; int i; int y, nHeight, nDevCount; int nStaticPos, nStaticWidth, nEditPos, nEditWidth, nButtonPos, nButtonWidth; HDC hDc; LPTSTR *ppszDevices; LPTSTR t_s; SIZE sz; LONG_PTR l; pDevViewInfo = GetDevViewInfo(hwndDevView); // clear out DevView_Clear(hwndDevView); // copy the config pDevViewInfo->config = config; // count total amount of devices nDevCount = 0; { for (bool gotone = pDevViewInfo->config->mconfig->devicelist().first(dev); gotone; gotone = dev->next(dev)) { nDevCount++; } } if (nDevCount > 0) { // get the names of all of the devices ppszDevices = (LPTSTR *) alloca(nDevCount * sizeof(*ppszDevices)); i = 0; for (bool gotone = pDevViewInfo->config->mconfig->devicelist().first(dev); gotone; gotone = dev->next(dev)) { t_s = tstring_from_utf8(dev->device().name()); ppszDevices[i] = (TCHAR*)alloca((_tcslen(t_s) + 1) * sizeof(TCHAR)); _tcscpy(ppszDevices[i], t_s); osd_free(t_s); i++; } // Calculate the requisite size for the device column pDevViewInfo->nWidth = 0; if (nDevCount > 0) { hDc = GetDC(hwndDevView); for (i = 0; i < nDevCount; i++) { GetTextExtentPoint32(hDc, ppszDevices[i], _tcslen(ppszDevices[i]), &sz); if (sz.cx > pDevViewInfo->nWidth) pDevViewInfo->nWidth = sz.cx; } ReleaseDC(hwndDevView, hDc); } pEnt = (struct DevViewEntry *) malloc(sizeof(struct DevViewEntry) * (nDevCount + 1)); if (!pEnt) return FALSE; memset(pEnt, 0, sizeof(struct DevViewEntry) * (nDevCount + 1)); pDevViewInfo->pEntries = pEnt; y = 10; nHeight = 21; DevView_GetColumns(hwndDevView, &nStaticPos, &nStaticWidth, &nEditPos, &nEditWidth, &nButtonPos, &nButtonWidth); for (bool gotone = pDevViewInfo->config->mconfig->devicelist().first(dev); gotone; gotone = dev->next(dev)) { pEnt->dev = dev; pEnt->hwndStatic = win_create_window_ex_utf8(0, "STATIC", dev->device().name(), WS_VISIBLE | WS_CHILD, nStaticPos, y, nStaticWidth, nHeight, hwndDevView, NULL, NULL, NULL); pEnt->hwndEdit = win_create_window_ex_utf8(0, "EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, nEditPos, y, nEditWidth, nHeight, hwndDevView, NULL, NULL, NULL); pEnt->hwndBrowseButton = win_create_window_ex_utf8(0, "BUTTON", "...", WS_VISIBLE | WS_CHILD, nButtonPos, y, nButtonWidth, nHeight, hwndDevView, NULL, NULL, NULL); if (pEnt->hwndStatic) { SendMessage(pEnt->hwndStatic, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); } if (pEnt->hwndEdit) { SendMessage(pEnt->hwndEdit, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); l = (LONG_PTR) DevView_EditWndProc; l = SetWindowLongPtr(pEnt->hwndEdit, GWLP_WNDPROC, l); pEnt->pfnEditWndProc = (WNDPROC) l; SetWindowLongPtr(pEnt->hwndEdit, GWLP_USERDATA, (LONG_PTR) pEnt); } if (pEnt->hwndBrowseButton) { SetWindowLongPtr(pEnt->hwndBrowseButton, GWLP_USERDATA, (LONG_PTR) pEnt); } y += nHeight; pEnt++; } } DevView_Refresh(hwndDevView); return TRUE; }