I'm writing a custom module to work with a proprietary software. (That software has been discontinued and I do not have its source code.) My module will run as a separate process. Its goal is to automate an operation via this proprietary software. To do that I need to be able to simulate saving the output from this software. I can bring up its Save As dialog via simulating a toolbar button click:
I then attempt to change the "Save as type" combo box to the file type required, add file path to save to, and simulate the click on the Save button. I came up with the following code to do that:
//All I have to work with are the following window handles:
//HWND hWndFileName = file name window handle
//HWND hWndSaveAsType = save as type window handle
//HWND hWndSaveBtn = Save button handle
DWORD dwComboIDSaveAsType = ::GetWindowLong(hWndSaveAsType, GWL_ID);
HWND hParWnd = ::GetParent(hWndSaveAsType);
//Select index for file type
int nSaveAsIndex = 3;
::SendMessage(hWndSaveAsType, CB_SETCURSEL, nSaveAsIndex, 0);
::SendMessage(hParWnd, WM_COMMAND,
(dwComboIDSaveAsType & 0xffff) | ((((DWORD)CBN_SELCHANGE) << 16) & 0xFFFF0000),
(LPARAM)hWndSaveAsType);
//Set path to save
::SendMessage(hWndFileName, WM_SETTEXT, NULL,
(LPARAM)L"C:\\Test\\test file");
//Simulate Save button click
::SendMessage(hWndSaveBtn, BM_CLICK, 0, 0);
Interestingly, the code above achieves the goal (by visually change the "Save as type" combo box) but when the file is saved, it still has the old, or originally selected type, i.e. "Quick Report file (.QRP)".
Any idea how to fix this?