#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include "Resource.h"
#include "MainDlg.h"
HWND currentWnd;
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
if(!IsWindowVisible(hwnd)){
return TRUE;
}
TCHAR title[256];
GetWindowText(hwnd,title,sizeof(title));
if(strlen(title) >0){
HWND hwdCombo1 = GetDlgItem(currentWnd,IDC_COMBO1);
ComboBox_AddString(hwdCombo1,title);
}
return TRUE;
}
BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}
return FALSE;
}
BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
currentWnd = hwnd;
HWND hwdCombo1 = GetDlgItem(hwnd,IDC_COMBO1);
ComboBox_AddString(hwdCombo1,TEXT("test"));
EnumWindows(EnumWindowsProc, lParam);
return TRUE;
}
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
{
HWND hwdCombo1 = GetDlgItem(hwnd,IDC_COMBO1);
ComboBox_AddString(hwdCombo1,TEXT("test"));
}
break;
default:
break;
}
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}