예제 #1
0
파일: brkdata.c 프로젝트: bencz/OrangeC
void RemoveDataBp(HWND hwnd)
{
    HWND hwndLV = GetDlgItem(hwnd, IDC_BPLIST);
    int k = ListView_GetSelectionMark(hwndLV);
    int n = ListView_GetItemCount(hwndLV);
    int i,j;
    for (i=n-1; i >=0; i--)
    {
        DATABREAK **search = &dataBpList, *found;
        LVITEM item;
        memset(&item, 0, sizeof(item));
        item.iItem = i;
        item.iSubItem = 0;
        item.mask = LVIF_STATE;
        item.stateMask = LVIS_SELECTED;	
        ListView_GetItem(hwndLV, &item);
        if (item.state & LVIS_SELECTED)
        {
            for (j=0; j <i; j++)
                search = &(*search)->next;
            found = *search;
            *search = found->next;
            free(found);
            ListView_DeleteItem(hwndLV, i);
        }
        ListView_SetSelectionMark(hwndLV, i);
        ListView_SetItemState(hwndLV, i, LVIS_SELECTED, LVIS_SELECTED);
    }
}
예제 #2
0
파일: brkdata.c 프로젝트: bencz/OrangeC
void AddDataBp(HWND hwnd)
{
    char *name = (char *)DialogBoxParam(hInstance, "ADDDATABPDIALOG", hwnd, 
        (DLGPROC)DataBpAddProc, 0);
    if (name)
    {
        DATABREAK **search = &dataBpList;
        DATABREAK *b = calloc(1, sizeof(DATABREAK));
        int v;
        HWND hwndLV = GetDlgItem(hwnd, IDC_BPLIST);
        LV_ITEM item;
        int i = ListView_GetItemCount(hwndLV);
        memset(&item, 0, sizeof(item));
        strcpy(b->name, name);
        while (*search)
            search = &(*search)->next;
        b->active = TRUE;
        *search = b;
        item.iItem = 10000;
        item.iSubItem = 0;
        item.mask = LVIF_PARAM;
        item.lParam = (LPARAM)b;
        v = ListView_InsertItem(hwndLV, &item);
        ListView_SetCheckState(hwndLV, v, TRUE);
        ListView_SetSelectionMark(hwndLV, i);
        ListView_SetItemState(hwndLV, i, LVIS_SELECTED, LVIS_SELECTED);
        
    }
}
예제 #3
0
	int ListView_SetCurSel (HWND hwnd , int pos) {
		ListView_Deselect(hwnd);
		ListView_SetItemState(hwnd , pos , LVIS_SELECTED , LVIS_SELECTED);
		ListView_SetSelectionMark(hwnd , pos);
		ListView_SetHotItem(hwnd , pos);
		ListView_EnsureVisible(hwnd , pos , 0);
		return 1;
	}
예제 #4
0
파일: extools.c 프로젝트: jossk/OrangeC
static void PopulateExToolsView(HWND hwnd, int sel, BOOL first)
{
    TOOL *curTools = tools;
    int items = 0;
    int i;
    LV_ITEM item;
    RECT r;
    HWND hwndLV = GetDlgItem(hwnd, IDC_EXTOOLCUSTOM);
    
    if (first)
    {
        LV_COLUMN lvC;
        ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
    
        GetWindowRect(hwndLV, &r);
        lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
        lvC.cx = 20;
        lvC.iSubItem = 0;
        ListView_InsertColumn(hwndLV, 0, &lvC);
        lvC.mask = LVCF_WIDTH | LVCF_SUBITEM;
        lvC.cx = 32;
        lvC.iSubItem = 1;
        ListView_InsertColumn(hwndLV, 1, &lvC);
        lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
        lvC.fmt = LVCFMT_LEFT;
        lvC.cx = r.right - r.left - 56;
        lvC.iSubItem = 2;
        ListView_InsertColumn(hwndLV, 2, &lvC);
    }
    else
    {
        ListView_DeleteAllItems(hwndLV);
    }
    
    start = TRUE;
    for (i=0; curTools; curTools = curTools->next, i++)
    {
        if (!curTools->removing)
        {
            int v;
            item.iItem = items++;
            item.iSubItem = 0;
            item.mask = LVIF_PARAM ;
            item.lParam = (LPARAM)i;
            item.pszText = ""; // LPSTR_TEXTCALLBACK ;
            v = ListView_InsertItem(hwndLV, &item);
            ListView_SetCheckState(hwndLV, v, curTools->enabled ? 1 : 0);
        }
    }
    start = FALSE;
    if (items)
    {
        ListView_SetSelectionMark(hwndLV, sel);
        ListView_SetItemState(hwndLV, sel, LVIS_SELECTED, LVIS_SELECTED);
    }

}
예제 #5
0
	bool select_single_item(HWND p_listview,unsigned p_index)
	{
		LRESULT temp = SendMessage(p_listview,LVM_GETITEMCOUNT,0,0);
		if (temp < 0) return false;
		ListView_SetSelectionMark(p_listview,p_index);
		unsigned n; const unsigned m = pfc::downcast_guarded<unsigned>(temp);
		for(n=0;n<m;n++) {
			enum {mask = LVIS_FOCUSED | LVIS_SELECTED};
			ListView_SetItemState(p_listview,n,n == p_index ? mask : 0, mask);
		}
		return ensure_visible(p_listview,p_index);
	}
예제 #6
0
// moves the caret to the given index, selects it, and ensures it is visible.
BOOL CQListCtrl::SetListPos( int index )
{
	if( index < 0 || index >= GetItemCount() )
		return FALSE;

	RemoveAllSelection();
	SetCaret(index);
	SetSelection(index);
	ListView_SetSelectionMark(m_hWnd, index);
	EnsureVisible(index,FALSE);

	return TRUE;
}
예제 #7
0
파일: brkdata.c 프로젝트: bencz/OrangeC
int LoadDataBreakpoints(HWND hwnd)
{
    int items = 0;
    int i;
    LV_ITEM item;
    RECT r;
    HWND hwndLV = GetDlgItem(hwnd, IDC_BPLIST);
    LV_COLUMN lvC;
    DATABREAK *search;
    ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);

    GetWindowRect(hwndLV, &r);
    lvC.mask = LVCF_WIDTH | LVCF_SUBITEM;
    lvC.cx = 20;
    lvC.iSubItem = 0;
    ListView_InsertColumn(hwndLV, 0, &lvC);
    lvC.mask = LVCF_WIDTH | LVCF_SUBITEM;
    lvC.cx = 32;
    lvC.iSubItem = 1;
    ListView_InsertColumn(hwndLV, 1, &lvC);
    lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
    lvC.fmt = LVCFMT_LEFT;
    lvC.cx = r.right - r.left - 56;
    lvC.iSubItem = 2;
    ListView_InsertColumn(hwndLV, 2, &lvC);


    search = dataBpList;
    while (search)
    {
        int v;
        BOOL b = search->active;
        memset(&item, 0, sizeof(item));
        item.iItem = 10000;
        item.iSubItem = 0;
        item.mask = LVIF_PARAM;
        item.lParam = (LPARAM)search;
        v = ListView_InsertItem(hwndLV, &item);
        ListView_SetCheckState(hwndLV, v, b);
        search = search->next;
    }
    if (items)
    {
        ListView_SetSelectionMark(hwndLV, 0);
        ListView_SetItemState(hwndLV, 0, LVIS_SELECTED, LVIS_SELECTED);
    }

    return items;
}
예제 #8
0
HRESULT CCListBox::SelectAnItem(int iItem)
{
    LVITEMW lvi = {0};
    lvi.iItem = iItem;
    lvi.iSubItem = 0;
    lvi.mask = LVIF_STATE;
    lvi.state = LVIS_SELECTED;
    lvi.stateMask = LVIS_SELECTED;

    if(ListView_SetItem(m_hWnd, &lvi) == FALSE)
    {
        return E_FAIL;
    }

    ListView_SetSelectionMark(m_hWnd, iItem);

    return S_OK;
}
예제 #9
0
파일: drawutil.c 프로젝트: jossk/OrangeC
static int CreateFileSaveData(HWND hwnd, int changed)
{
    int items = 0;
    DWINFO *ptr;
    RECT r;
    HWND hwndLV = GetDlgItem(hwnd, IDC_FILELIST);
    LV_COLUMN lvC;
    ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);

    GetWindowRect(hwndLV, &r);
    lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
    lvC.cx = 20;
    lvC.iSubItem = 0;
    ListView_InsertColumn(hwndLV, 0, &lvC);
    lvC.mask = LVCF_WIDTH | LVCF_SUBITEM;
    lvC.cx = 32;
    lvC.iSubItem = 1;
    ListView_InsertColumn(hwndLV, 1, &lvC);
    lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
    lvC.fmt = LVCFMT_LEFT;
    lvC.cx = r.right - r.left - 56;
    lvC.iSubItem = 2;
    ListView_InsertColumn(hwndLV, 2, &lvC);

    MsgWait(ewSem, INFINITE);
    ptr = editWindows;
    while (ptr)
    {
        ptr->inSaveDialog = FALSE;
        ptr = ptr->next;
    }
    SetEvent(ewSem);
    if (workArea)
        GetFileList(hwndLV, workArea, &items, changed);
    GetSecondaryFileList(hwndLV, &items, changed);
    
    if (items)
    {
        ListView_SetSelectionMark(hwndLV, 0);
        ListView_SetItemState(hwndLV, 0, LVIS_SELECTED, LVIS_SELECTED);
    }

    return items;
}
예제 #10
0
static int add_row_tablewindow(TABLE_WINDOW *win,HWND hlistview)
{
	int i,count,row;
	if(win==0 || hlistview==0)
		return FALSE;
	count=ListView_GetItemCount(win->hlistview);
	row=ListView_GetSelectionMark(win->hlistview);
	if(row<0)
		row=count;
	else
		row++;
	count=ListView_GetItemCount(hlistview);
	for(i=0;i<count;i++){
		char str[255]={0};
		ListView_GetItemText(hlistview,i,DATA_POS,str,sizeof(str));
		lv_insert_data(win->hlistview,row,i,str);
	}
	ListView_EnsureVisible(win->hlistview,row,FALSE);
	ListView_SetSelectionMark(win->hlistview,row);
	ListView_SetItemState(win->hlistview,row,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
	return TRUE;
}
예제 #11
0
파일: prjfile.c 프로젝트: jossk/OrangeC
long APIENTRY NewFileProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
    lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
           if (!CreateNewFileData(hwnd))
           {
                EndDialog(hwnd, 1);
           }
            else
            {
                CenterWindow(hwnd);
            }
            return 1;
        case WM_NOTIFY:
            if (((LPNMHDR)lParam)->code == NM_CUSTOMDRAW)
            {
                SetWindowLong(hwnd, DWL_MSGRESULT, CustomDrawNewFile(hwnd, (LPNMLVCUSTOMDRAW)lParam));
                return TRUE;
            }
            else if (((LPNMHDR)lParam)->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case VK_INSERT:
                        if (GetKeyState(VK_CONTROL) & 0x80000000)
                        {
                            HWND hwndLV = GetDlgItem(hwnd, IDC_LVNEWFILE);
                            ListView_SetSelectionMark(hwndLV, -1);
                        }
                        else
                        {
                            HWND hwndLV = GetDlgItem(hwnd, IDC_LVNEWFILE);
                            int i = ListView_GetSelectionMark(hwndLV);
                            ListView_SetSelectionMark(hwndLV, i);
                            ListView_SetItemState(hwndLV, i, LVIS_SELECTED, LVIS_SELECTED);
                        }
                        break;
                }
            }
            return 0;
        case WM_COMMAND:
            switch (wParam &0xffff)
            {
            case IDOK:
                if (ParseNewFileData(hwnd))
                    EndDialog(hwnd, IDOK);
                break;
            case IDCANCEL:
                EndDialog(hwnd, IDCANCEL);
                break;
            case IDHELP:
                ContextHelp(IDH_NEW_FILE_DIALOG);
                break;
            }
            break;
        case WM_CLOSE:
            PostMessage(hwnd, WM_COMMAND, IDCANCEL, 0);
            break;
    }
    return 0;
}
예제 #12
0
파일: prjfile.c 프로젝트: jossk/OrangeC
static int CreateNewFileData(HWND hwnd)
{
    int items = 0;
    LV_ITEM item;
    RECT r;
    HWND hwndLV = GetDlgItem(hwnd, IDC_LVNEWPROJECT);
    LV_COLUMN lvC;
    ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
    ListView_SetImageList(hwndLV, ImageList_Duplicate(treeIml), LVSIL_SMALL);

    GetWindowRect(hwndLV, &r);
    lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
    lvC.cx = r.right - r.left;
    lvC.iSubItem = 0;
    ListView_InsertColumn(hwndLV, 0, &lvC);

    memset(&item, 0, sizeof(item));
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_C;
    item.pszText = "C Program File";
    item.lParam = 0;
    ListView_InsertItem(hwndLV, &item);
    
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_H;
    item.pszText = "Header File";
    item.lParam = 6;
    ListView_InsertItem(hwndLV, &item);
    
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_RES;
    item.pszText = "Resource File";
    item.lParam = 11;
    ListView_InsertItem(hwndLV, &item);
    
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_FILES;
    item.pszText = "Module Definition File";
    item.lParam = 5;
    ListView_InsertItem(hwndLV, &item);
    
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_ASM;
    item.pszText = "Assembly Language File";
    item.lParam = 3;
    ListView_InsertItem(hwndLV, &item);
    
    item.iItem = items++;
    item.iSubItem = 0;
    item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
    item.iImage = IL_FILES;
    item.pszText = "Text File";
    item.lParam = 16;
    ListView_InsertItem(hwndLV, &item);
    
    ListView_SetSelectionMark(hwndLV, 0);
    ListView_SetItemState(hwndLV, 0, LVIS_SELECTED, LVIS_SELECTED);

    SendDlgItemMessage(hwnd, IDC_FILENEWFILE, WM_SETTEXT, 0, (LPARAM) "");
    SendDlgItemMessage(hwnd, IDC_FILENEWFILE, EM_SETLIMITTEXT, MAX_PATH, 0);
    return items;
}
예제 #13
0
/**
 * name:	ListSubclassProc
 * desc:	procedure to catch messages for a listview control, to handle tooltips
 * param:	hwnd	- handle to the listview control's window
 *			msg		- message sent to the control
 *			wParam	- message specific parameter
 *			lParam	- message specific parameter
 * return:	message specific
 **/
static INT_PTR CALLBACK ProfileList_SubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	LPLISTCTRL pList;

	switch (msg) {
		case WM_KEYDOWN:
		{
			INT nCurSel, newSel;
			LVITEM lvi;

			switch (wParam) {
				case VK_F2:
					nCurSel = ListView_GetSelectionMark(hwnd);
					if (nCurSel == -1) break;
					ProfileList_BeginLabelEdit(hwnd, nCurSel, 0);
					return 0;
				case VK_F3:
					nCurSel = ListView_GetSelectionMark(hwnd);
					if (nCurSel == -1) break;
					ProfileList_BeginLabelEdit(hwnd, nCurSel, 1);
					return 0;
				case VK_UP:
				case VK_DOWN:
					lvi.iItem = nCurSel = ListView_GetSelectionMark(hwnd);
					lvi.iSubItem = 0;

					// find next valid item to select
					lvi.mask = LVIF_PARAM;
					do {
						if (wParam == VK_UP) lvi.iItem--;
						else lvi.iItem++;
						if (lvi.iItem == -1 || !ListView_GetItem(hwnd, &lvi)) {
							return 0;
						}
					} while (!lvi.lParam);

					ListView_EnsureVisible(hwnd, lvi.iItem, FALSE);
					newSel = lvi.iItem;
					lvi.iItem = nCurSel;
					lvi.mask = LVIF_STATE;
					lvi.stateMask = LVIS_FOCUSED|LVIS_SELECTED;
					lvi.state = 0;
					ListView_SetItem(hwnd, &lvi);
					lvi.iItem = newSel;
					lvi.state = LVIS_FOCUSED|LVIS_SELECTED;
					ListView_SetItem(hwnd, &lvi);
					ListView_SetSelectionMark(hwnd, lvi.iItem);
					return 0;
			}
			break;
		}
		case WM_MOUSEMOVE:
			if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) {
				HDC hDC;
				RECT rchWnd, rcItem;
				SIZE textSize;
				LVHITTESTINFO hi;
				TOOLINFO ti;
				BOOLEAN bReposition;
				LPLCITEM pItem;
							
				hi.pt.x = GET_X_LPARAM(lParam);
				hi.pt.y = GET_Y_LPARAM(lParam);
				ListView_SubItemHitTest(hwnd, &hi);

				// show tip only if pointer is over an item
				if (pList->iHotItem != hi.iItem || pList->iHotSubItem != hi.iSubItem) {
					bReposition = pList->iHotItem != -1 || pList->iHotSubItem != -1;
					pList->iHotItem = hi.iItem;
					pList->iHotSubItem = hi.iSubItem;
					
					if ((hi.flags & LVHT_ONITEMLABEL) && PtrIsValid(pItem = ProfileList_GetItemData(hwnd, hi.iItem))) {
						GetWindowRect(hwnd, &rchWnd);
						ListView_GetSubItemRect(hwnd, hi.iItem, hi.iSubItem, LVIR_BOUNDS, &rcItem);
						// calculate size of text on the screen
						if ((hDC = GetDC(GetParent(hwnd)))) {
							SelectObject(hDC, (HFONT)SendMessage(GetParent(hwnd), WM_GETFONT, NULL, NULL));
							GetTextExtentPoint32(hDC, pItem->pszText[hi.iSubItem], lstrlen(pItem->pszText[hi.iSubItem]), &textSize);
							ReleaseDC(GetParent(hwnd), hDC);
						}
						// show tip only for text that is larger than te listview can display
						if (textSize.cx > rchWnd.right - rchWnd.left || textSize.cx > rcItem.right - rcItem.left) {
							ZeroMemory(&ti, sizeof(TOOLINFO));
							ti.cbSize = sizeof(TOOLINFO);
							ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS|TTF_TRANSPARENT;
							ti.hinst = ghInst;
							ti.hwnd = hwnd;
							ti.uId = (UINT_PTR)hwnd;
							ti.lpszText = pItem->pszText[hi.iSubItem];
							ti.rect = rcItem;
							SendMessage(pList->hTip, TTM_SETMAXTIPWIDTH, 0, 300);
							SendMessage(pList->hTip, TTM_SETTOOLINFO, NULL, (LPARAM)&ti);
							if (pList->iHotSubItem > 0) {
								SendMessage(pList->hTip, TTM_SETTITLE, 1, (LPARAM)
									((pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount)
									? pItem->idstrList[pItem->iListItem].ptszTranslated
										: (pItem->pszText[0] && *pItem->pszText[0])
											? pItem->pszText[0]
											: TranslateT("<empty>"))
							);
								InvalidateRect(pList->hTip, NULL, TRUE);
							}
							else
								SendMessage(pList->hTip, TTM_SETTITLE, 0, (LPARAM)"");
							SendMessage(pList->hTip, TTM_ACTIVATE, TRUE, (LPARAM)&ti);
							pList->ptTip.x = rchWnd.left + GET_X_LPARAM(lParam) - 16;
							pList->ptTip.y = rchWnd.top + rcItem.top;
							// no TTN_SHOW is called if bReposition is TRUE, so repose here!
							if (bReposition) {
								RECT rcTip;
								GetClientRect(pList->hTip, &rcTip);
								SetWindowPos(pList->hTip, hwnd, pList->ptTip.x, pList->ptTip.y - rcTip.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
							}
							pList->wFlags |= LIF_TIPVISIBLE;
							return 0;
						}
					}
					if (pList->wFlags & LIF_TIPVISIBLE) {
						SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti);
						pList->wFlags &= ~LIF_TIPVISIBLE;
					}
				}
			}
			return 0;

			// begin label edit
			case WM_LBUTTONDBLCLK:
			{
				LVHITTESTINFO hi;

				hi.pt.x = GET_X_LPARAM(lParam);
				hi.pt.y = GET_Y_LPARAM(lParam);
				if (ListView_SubItemHitTest(hwnd, &hi)) {
					ProfileList_BeginLabelEdit(hwnd, hi.iItem, hi.iSubItem);
				}
				return TRUE;
			}
			
		case WM_NOTIFY:
			if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd)))
				break;
		
			// ensure position of tooltip is on the topline of the item
			if (((LPNMHDR)lParam)->hwndFrom == pList->hTip) {
				RECT rcTip;
				GetClientRect(pList->hTip, &rcTip);
				
				switch (((LPNMHDR)lParam)->code) {
					case TTN_SHOW:
						SetWindowPos(pList->hTip, hwnd, pList->ptTip.x, pList->ptTip.y - rcTip.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
						return TRUE;
				}
			}
			break;
		case WM_COMMAND:
		{
			switch (LOWORD(wParam)) {

				// show dropdown menu for category list
				case BTN_EDIT:
				{
					INT i;
					TCHAR szEdit[MAX_PATH];

					if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) break;
					GetWindowText(pList->labelEdit.hEdit, szEdit, MAX_PATH);

					// need to create the dropdown list?
					if (pList->labelEdit.dropDown.hDrop == NULL) {
						const INT listHeight = 120;
						RECT rc, rcList;
						INT add;

						// dropdown rect
						GetClientRect(pList->hList, &rcList);
						rc.left = pList->labelEdit.rcCombo.left;
						rc.right = pList->labelEdit.rcCombo.right + pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top; 
						
						if (rcList.bottom < pList->labelEdit.rcCombo.bottom + listHeight) {
							rc.bottom = pList->labelEdit.rcCombo.bottom - 7; // don't ask me why!
							rc.top = rc.bottom - listHeight;
						}
						else {
							rc.top = pList->labelEdit.rcCombo.bottom;
							rc.bottom = rc.top + listHeight;
						}

						pList->labelEdit.dropDown.hDrop = CreateWindowEx(0,
									_T("LISTBOX"), NULL, WS_CHILD|WS_BORDER|WS_VSCROLL|LBS_COMBOBOX|LBS_HASSTRINGS,
									rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
									hwnd, NULL, ghInst, NULL);
						if (!pList->labelEdit.dropDown.hDrop) return FALSE;
						SetUserData(pList->labelEdit.dropDown.hDrop, pList);
						OldDropdownProc = (WNDPROC)SetWindowLongPtr(pList->labelEdit.dropDown.hDrop, GWLP_WNDPROC, (LONG_PTR)ProfileList_DropdownProc);
						SetWindowLongPtr(pList->labelEdit.dropDown.hDrop, GWLP_ID, LIST_DROPDOWN);
						SendMessage(pList->labelEdit.dropDown.hDrop, WM_SETFONT, (WPARAM)SendMessage(GetParent(pList->hList), WM_GETFONT, 0, 0), 0);
						
						// add items
						for (i = 0; i < pList->labelEdit.pItem->idstrListCount; i++) {
							add = ListBox_AddString(pList->labelEdit.dropDown.hDrop, pList->labelEdit.pItem->idstrList[i].ptszTranslated);
							ListBox_SetItemData(pList->labelEdit.dropDown.hDrop, add, pList->labelEdit.pItem->idstrList + i);
							if (!_tcscmp(szEdit, pList->labelEdit.pItem->idstrList[i].ptszTranslated))
								ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, add);
						}
					}
					else {
						LPIDSTRLIST lpidList;

						i = 0;
						while (PtrIsValid(lpidList = (LPIDSTRLIST)ListBox_GetItemData(pList->labelEdit.dropDown.hDrop, i))) {
							if (!_tcscmp(szEdit, lpidList->ptszTranslated)) {
								ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, i);
								break;
							}
							i++;
						}
						if (i == pList->labelEdit.pItem->idstrListCount) 
							ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, -1);
					}
					if (IsWindowVisible(pList->labelEdit.dropDown.hDrop)) {
						SetFocus(pList->labelEdit.hEdit);
					}
					else {
						ShowWindow(pList->labelEdit.dropDown.hDrop, SW_SHOW);
						//SetFocus(pList->labelEdit.dropDown.hDrop);
					}
					break;
				}
			}
			break;
		}
		case WM_MOUSEWHEEL:
		case WM_VSCROLL:
		case WM_HSCROLL:
		{
			if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd)))
				ProfileList_EndLabelEdit(pList, FALSE);
			break;
		}

		case WM_KILLFOCUS:
		{
			HWND hwndFocus = GetFocus();

			if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd)) &&
				pList->labelEdit.hEdit != hwndFocus && 
				pList->labelEdit.dropDown.hDrop != hwndFocus && 
				pList->labelEdit.hBtn != hwndFocus)
				ProfileList_EndLabelEdit(pList, FALSE);
			break;
		}

		case WM_DESTROY:
			if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) {
				HFONT hFont;

				ProfileList_EndLabelEdit(pList, FALSE);
				ProfileList_Clear(hwnd);
				if (PtrIsValid(hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0)) && hFont != pList->hFont)
					DeleteObject(hFont);
				DestroyWindow(pList->hTip);
				mir_free(pList);
			}
			break;
	}
	return CallWindowProc(OldListViewProc, hwnd, msg, wParam, lParam);
}
예제 #14
0
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;
	static int watchIndex=0;

	Update_RAM_Watch();

	switch(uMsg)
	{
		case WM_MOVE: {
			RECT wrect;
			GetWindowRect(hDlg,&wrect);
			ramw_x = wrect.left;
			ramw_y = wrect.top;
			break;
			};
			
		case WM_INITDIALOG: {
			GetWindowRect(MainWindow->getHWnd(), &r);  //Ramwatch window
			dx1 = (r.right - r.left) / 2;
			dy1 = (r.bottom - r.top) / 2;

			GetWindowRect(hDlg, &r2); // Gens window
			dx2 = (r2.right - r2.left) / 2;
			dy2 = (r2.bottom - r2.top) / 2;

			
			// push it away from the main window if we can
			const int width = (r.right-r.left);
			const int height = (r.bottom - r.top);
			const int width2 = (r2.right-r2.left); 
			if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN))
			{
				r.right += width;
				r.left += width;
			}
			else if((int)r.left - (int)width2 > 0)
			{
				r.right -= width2;
				r.left -= width2;
			}
			
			//-----------------------------------------------------------------------------------
			//If user has Save Window Pos selected, override default positioning
			if (RWSaveWindowPos)	
			{
				//If ramwindow is for some reason completely off screen, use default instead 
				if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN))   ) 
					r.left = ramw_x;	  //This also ignores cases of windows -32000 error codes
				//If ramwindow is for some reason completely off screen, use default instead 
				if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN))	)
					r.top = ramw_y;		  //This also ignores cases of windows -32000 error codes
			}
			//-------------------------------------------------------------------------------------
			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
			
			ramwatchmenu=GetMenu(hDlg);
			rwrecentmenu=CreateMenu();
			UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE);
			
			const char* names[3] = {"Address","Value","Notes"};
			int widths[3] = {62,64,64+51+53};
			init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths);
/*			if (!ResultCount)  //TODO what do these do
				reset_address_info();
			else
				signal_new_frame();*/
			ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
//			if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0);
//			if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0);

			RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1));

			// due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here
			SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE);
			Update_RAM_Watch();
			DragAcceptFiles(hDlg, TRUE);

			return true;
			break;
		}
		
		case WM_INITMENU:
			CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED);
			CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED);
			break;

		case WM_MENUSELECT:
 		case WM_ENTERSIZEMOVE:
			break;

		case WM_NOTIFY:
		{
			switch(wParam)
			{
				case ID_WATCHES_UPDOWN:
				{
					switch(((LPNMUPDOWN)lParam)->hdr.code)
					{
						case UDN_DELTAPOS:
							int delta = ((LPNMUPDOWN)lParam)->iDelta;
							SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0);
							break;
					}
				}

				default:
				{
					LPNMHDR lP = (LPNMHDR) lParam;
					switch (lP->code)
					{
						case LVN_GETDISPINFO:
						{
							LV_DISPINFO *Item = (LV_DISPINFO *)lParam;
							Item->item.mask = LVIF_TEXT;
							Item->item.state = 0;
							Item->item.iImage = 0;
							const unsigned int iNum = Item->item.iItem;
							static char num[11];
							switch (Item->item.iSubItem)
							{
								case 0:
									sprintf(num,"%08X",rswatches[iNum].Address);
									Item->item.pszText = num;
									return true;
								case 1: {
									int i = rswatches[iNum].CurValue;
									int t = rswatches[iNum].Type;
									int size = rswatches[iNum].Size;
									const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X"));
									switch (size)
									{
										case 'b':
										default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
										case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
										case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
									}

									Item->item.pszText = num;
								}	return true;
								case 2:
									Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : "";
									return true;

								default:
									return false;
							}
						}
						case LVN_ODFINDITEM:
						{	
							// disable search by keyboard typing,
							// because it interferes with some of the accelerators
							// and it isn't very useful here anyway
							SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)));
							return 1;
						}
					}
				}
			}
			break;
		}

		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case RAMMENU_FILE_SAVE:
					QuickSaveWatches();
					break;

				case RAMMENU_FILE_SAVEAS:	
					return Save_Watches();
				case RAMMENU_FILE_OPEN:
					return Load_Watches(true);
				case RAMMENU_FILE_APPEND:
					return Load_Watches(false);
				case RAMMENU_FILE_NEW:
					ResetWatches();
					return true;
				case IDC_C_WATCH_REMOVE:
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
					RemoveWatch(watchIndex);
					ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);	
					RWfileChanged=true;
					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
					return true;
				case IDC_C_WATCH_EDIT:
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
					DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex);
					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
					return true;
				case IDC_C_WATCH:
					rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0;
					rswatches[WatchCount].Size = 'b';
					rswatches[WatchCount].Type = 's';
					DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
					return true;
				case IDC_C_WATCH_DUPLICATE:
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
					rswatches[WatchCount].Address = rswatches[watchIndex].Address;
					rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian;
					rswatches[WatchCount].Size = rswatches[watchIndex].Size;
					rswatches[WatchCount].Type = rswatches[watchIndex].Type;
					DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
					return true;
				case IDC_C_WATCH_UP:
				{
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
					if (watchIndex == 0 || watchIndex == -1)
						return true;
					void *tmp = malloc(sizeof(AddressWatcher));
					memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher));
					memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher));
					memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher));
					free(tmp);
					ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1);
					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
					ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
					RWfileChanged=true;
					return true;
				}
				case IDC_C_WATCH_DOWN:
				{
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
					if (watchIndex >= WatchCount - 1 || watchIndex == -1)
						return true;
					void *tmp = malloc(sizeof(AddressWatcher));
					memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher));
					memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher));
					memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher));
					free(tmp);
					ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1);
					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
					ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
					RWfileChanged=true;
					return true;
				}
				case RAMMENU_FILE_AUTOLOAD:
				{
					AutoRWLoad ^= 1;
					CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED);
					break;
				}
				case RAMMENU_FILE_SAVEWINDOW:
				{
					RWSaveWindowPos ^=1;
					CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED);
					break;
				}
				case IDC_C_ADDCHEAT:
				{
					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)) | (1 << 24);
//					DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex);	//TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system
					break;
				}
				case IDCANCEL:
					RamWatchHWnd = NULL;
					DragAcceptFiles(hDlg, FALSE);
					EndDialog(hDlg, true);
					return true;
				default:
					if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES)
					OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE);
			}
			break;
		
		case WM_KEYDOWN: // handle accelerator keys
		{
			SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
			MSG msg;
			msg.hwnd = hDlg;
			msg.message = uMsg;
			msg.wParam = wParam;
			msg.lParam = lParam;
			if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg))
				return true;
		}	break;

		case WM_CLOSE:
			RamWatchHWnd = NULL;
			DragAcceptFiles(hDlg, FALSE);
			EndDialog(hDlg, true);
			return true;

		case WM_DROPFILES:
		{
			HDROP hDrop = (HDROP)wParam;
			DragQueryFile(hDrop, 0, Str_Tmp, 1024);
			DragFinish(hDrop);
			return Load_Watches(true, Str_Tmp);
		}	break;
	}

	return false;
}
예제 #15
0
int CCListBox::SetSelectionMark(int i)
{
    return ListView_SetSelectionMark(m_hWnd, i);
}
예제 #16
0
LRESULT CALLBACK insert_dlg_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	static TABLE_WINDOW *win=0;
	static HWND hlistview=0,hgrippy=0,hedit=0;
	static HFONT hfont=0;
	static WNDPROC origlistview=0;
	if(FALSE)
	{
		static DWORD tick=0;
		if((GetTickCount()-tick)>500)
			printf("--\n");
		if(hwnd==hlistview)
			printf("-");
		print_msg(msg,lparam,wparam,hwnd);
		tick=GetTickCount();
	}
	if(origlistview!=0 && hwnd==hlistview){
		if(msg==WM_GETDLGCODE){
			return DLGC_WANTARROWS;
		}
		return CallWindowProc(origlistview,hwnd,msg,wparam,lparam);
	}
	switch(msg){
	case WM_INITDIALOG:
		if(lparam==0){
			EndDialog(hwnd,0);
			break;
		}
		hedit=0;
		win=lparam;
		hlistview=CreateWindow(WC_LISTVIEW,"",WS_TABSTOP|WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|LVS_REPORT|LVS_SHOWSELALWAYS,
                                     0,0,
                                     0,0,
                                     hwnd,
                                     IDC_LIST1,
                                     ghinstance,
                                     NULL);
		if(hlistview!=0){
			ListView_SetExtendedListViewStyle(hlistview,LVS_EX_FULLROWSELECT);
			hfont=SendMessage(win->hlistview,WM_GETFONT,0,0);
			if(hfont!=0)
				SendMessage(hlistview,WM_SETFONT,hfont,0);
			populate_insert_dlg(hwnd,hlistview,win);
			ListView_SetItemState(hlistview,0,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
			origlistview=SetWindowLong(hlistview,GWL_WNDPROC,(LONG)insert_dlg_proc);
		}
		set_title(hwnd,win);
		hgrippy=create_grippy(hwnd);
		resize_insert_dlg(hwnd);
		break;
	case WM_NOTIFY:
		{
			NMHDR *nmhdr=lparam;
			if(nmhdr!=0){
				switch(nmhdr->code){
				case NM_DBLCLK:
					if(hedit==0 && nmhdr->hwndFrom==hlistview)
						SendMessage(hwnd,WM_COMMAND,IDOK,0);
					break;
				case  LVN_COLUMNCLICK:
					{
						static sort_dir=0;
						NMLISTVIEW *nmlv=lparam;
						if(nmlv!=0){
							sort_listview(hlistview,sort_dir,nmlv->iSubItem);
							sort_dir=!sort_dir;
						}
					}
					break;
				case LVN_KEYDOWN:
					if(nmhdr->hwndFrom==hlistview)
					{
						LV_KEYDOWN *key=lparam;
						switch(key->wVKey){
						case VK_DOWN:
						case VK_RIGHT:
						case VK_NEXT:
							{
								int count,row_sel;
								count=ListView_GetItemCount(hlistview);
								row_sel=ListView_GetSelectionMark(hlistview);
								if(count>0 && row_sel==count-1)
									SetFocus(GetDlgItem(hwnd,IDOK));
							}
							break;
						case VK_DELETE:
							clear_selected_items(hlistview);
							break;
						case VK_F5:
							if(task_insert_row(win,hlistview))
								SetWindowText(GetDlgItem(hwnd,IDOK),"Busy");
							break;
						case 'A':
							if(GetKeyState(VK_CONTROL)&0x8000){
								int i,count;
								count=ListView_GetItemCount(hlistview);
								for(i=0;i<count;i++){
									ListView_SetItemState(hlistview,i,LVIS_SELECTED,LVIS_SELECTED);
								}
								break;
							}
						default:
							{
								int ignore=FALSE;
								if(!is_entry_key(key->wVKey))
									ignore=TRUE;
								if(GetKeyState(VK_CONTROL)&0x8000)
									ignore=TRUE;
								if(ignore)
									return 1;
							}
						case ' ':
						case VK_F2:
						case VK_INSERT:
							{
								int row_sel=ListView_GetSelectionMark(hlistview);
								if(row_sel>=0 && hedit==0){
									hedit=CreateWindow("EDIT","",WS_THICKFRAME|WS_TABSTOP|WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|
											ES_LEFT|ES_AUTOHSCROLL,
											0,0,
											0,0,
											hwnd,
											IDC_EDIT1,
											ghinstance,
											NULL);
									if(hedit!=0){
										RECT rect={0},crect={0};
										int x,y,w,h;
										ListView_GetItemRect(hlistview,row_sel,&rect,LVIR_BOUNDS);
										lv_get_col_rect(hlistview,DATA_POS,&crect);
										x=crect.left-2;
										y=rect.top-2;
										w=crect.right-crect.left+8;
										h=rect.bottom-rect.top+8;
										SetWindowPos(hedit,HWND_TOP,x,y,w,h,0);
										if(hfont!=0)
											SendMessage(hedit,WM_SETFONT,hfont,0);
										if(is_entry_key(key->wVKey)){
											char str[2];
											char c=tolower(key->wVKey);
											if((GetKeyState(VK_SHIFT)&0x8000) || (GetKeyState(VK_CAPITAL)&1))
												c=toupper(c);
											str[0]=c;
											str[1]=0;
											SetWindowText(hedit,str);
											SendMessage(hedit,EM_SETSEL,1,1);

										}else{
											populate_edit_control(hlistview,hedit,row_sel);
										}
										SetFocus(hedit);
										wporigtedit=SetWindowLong(hedit,GWL_WNDPROC,(LONG)sc_edit);
									}
								}
							}
							break;
						}

					}
					break;
				}

			}
		}
		break;
	case WM_HSCROLL:
		if(lparam==hgrippy)
			SetFocus(hlistview);
		break;
	case WM_USER:
		if(hedit!=0 && lparam==hedit){
			hedit=0;
			SetFocus(hlistview);
		}
		else if(lparam==hlistview){
			if(wparam==IDOK){
				add_row_tablewindow(win,hlistview);
			}
			else
				SetFocus(GetDlgItem(hwnd,IDCANCEL));

			SetWindowText(GetDlgItem(hwnd,IDOK),"OK");
		}
		break;
	case WM_SIZE:
		resize_insert_dlg(hwnd);
		grippy_move(hwnd,hgrippy);
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDOK:
			if(hedit!=0){
				if(GetFocus()==hedit){
					char str[80]={0};
					int count,row_sel=ListView_GetSelectionMark(hlistview);
					GetWindowText(hedit,str,sizeof(str));
					resize_column(hwnd,hlistview,str,1);
					lv_update_data(hlistview,row_sel,DATA_POS,str);
					SendMessage(hedit,WM_CLOSE,0,0);
					count=ListView_GetItemCount(hlistview);
					if(row_sel < (count-1)){
						ListView_SetItemState(hlistview,row_sel,0,LVIS_SELECTED|LVIS_FOCUSED);
						row_sel++;
						ListView_SetItemState(hlistview,row_sel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
						ListView_SetSelectionMark(hlistview,row_sel);
					}
					hedit=0;
				}
				break;
			}
			else if(GetFocus()==hlistview){
				static LV_KEYDOWN lvk={0};
				lvk.hdr.hwndFrom=hlistview;
				lvk.hdr.code=LVN_KEYDOWN;
				lvk.wVKey=VK_INSERT;
				SendMessage(hwnd,WM_NOTIFY,0,&lvk);
				break;
			}
			else{
				if(task_insert_row(win,hlistview))
					SetWindowText(GetDlgItem(hwnd,IDOK),"Busy");

			}
			break;
		case IDCANCEL:
			if(hedit!=0){
				SendMessage(hedit,WM_CLOSE,0,0);
				hedit=0;
				break;
			}
			EndDialog(hwnd,0);
			break;
		}
		break;	
	}
	return 0;
}