Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Cybersecurity: email, utenti e agenti IA, la nuova visione di Proofpoint
Cybersecurity: email, utenti e agenti IA, la nuova visione di Proofpoint
Dal palco di Proofpoint Protect 2025 emerge la strategia per estendere la protezione dagli utenti agli agenti IA con il lancio di Satori Agents, nuove soluzioni di governance dei dati e partnership rafforzate che ridisegnano il panorama della cybersecurity
Hisense A85N: il ritorno all’OLED è convincente e alla portata di tutti
Hisense A85N: il ritorno all’OLED è convincente e alla portata di tutti
Dopo alcuni anni di assenza dai cataloghi dei suoi televisori, Hisense riporta sul mercato una proposta OLED che punta tutto sul rapporto qualità prezzo. Hisense 55A85N è un televisore completo e versatile che riesce a convincere anche senza raggiungere le vette di televisori di altra fascia (e altro prezzo)
Recensione Borderlands 4, tra divertimento e problemi tecnici
Recensione Borderlands 4, tra divertimento e problemi tecnici
Gearbox Software rilancia la saga con Borderlands 4, ora disponibile su PS5, Xbox Series X|S e PC. Tra le novità spiccano nuove abilità di movimento, un pianeta inedito da esplorare e una campagna che lascia al giocatore piena libertà di approccio
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 31-03-2010, 09:13   #1
giovannigiorgio
Bannato
 
Iscritto dal: Feb 2004
Messaggi: 58
[API WIN32] Inserire il testo di una editibox nella listview di un'altra finestra?

Ciao a tutti,
Ho una applicazione multiwindow. Voglio inserire il testo di una editbox di una finestra nella listview contenuta in un'altra finestra. Non riesco a trovare il modo. Qualcuno mi aiuta?
Grazie.
Vi posto il codice funzionante ma senza quello che voglio io.
Codice:
#include  <windows.h>
#include  <stdio.h>
#include  <commctrl.h>

#pragma comment(lib, "comctl32.lib")


typedef struct
{
   char  szItemNr[8];
   char  szItem[78];
   char  szItemDescription[32];
}Item;
//Beep(500,400);
// function prototypes
void InitApp(HINSTANCE);
LRESULT APIENTRY MainProc(HWND,UINT,WPARAM,LPARAM);
LRESULT APIENTRY OtherProc(HWND,UINT,WPARAM,LPARAM);

const int  ID_LISTVIEW =1;
const int SAVE=5;
const int CANCEL=6;
const int nEditID =4;
const int NUOVO= 2;
const int MODIFICA =3;
// variables
static HWND hwndED;
static HWND hwnd;
static HWND other;
static HWND edit;
static HWND add;
static   HWND           hWndListView;
static HINSTANCE g_hInst,hInstance;


static HWND hwndCombo;
//questo procurava segni strani nella listview quando compariva in altre parti del file
static   HFONT          hFont;
int agg(int x, int y)
{
    return x + y;
}
void InitApp(HINSTANCE hInst)
{
	INITCOMMONCONTROLSEX    icex, idex;
	WNDCLASS wc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
	wc.hInstance = hInst;
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
	wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
	wc.lpfnWndProc = (WNDPROC) MainProc;
	wc.lpszClassName = "Main";
	wc.lpszMenuName = NULL;
	wc.style = CS_HREDRAW | CS_VREDRAW;

	RegisterClass(&wc);

	wc.lpszClassName = "Other";
	wc.lpfnWndProc = (WNDPROC) OtherProc;

	RegisterClass(&wc);
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
   icex.dwICC = ICC_LISTVIEW_CLASSES;
   idex.dwSize=sizeof(INITCOMMONCONTROLSEX);
   idex.dwICC=ICC_DATE_CLASSES;
  InitCommonControlsEx(&icex);
  InitCommonControlsEx(&idex);
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
	hwnd = CreateWindow("Main","Reminder",WS_OVERLAPPEDWINDOW,(nScreenWidth-1000)/2, (nScreenHeight-600)/2,1000,600, NULL, NULL,hInst,0);
	other = CreateWindow("Other","",WS_OVERLAPPEDWINDOW,(nScreenWidth-1000)/2, (nScreenHeight-600)/2,1000,600, NULL, NULL,hInst,0);

	ShowWindow(hwnd,SW_SHOW);
	UpdateWindow(hwnd);
	
}

BOOL AdjustListView(HWND hList, LV_ITEM *lv, int iItems)
{
   int i = iItems;
   int iRet;
   ListView_DeleteAllItems(hList);

   lv->mask = LVIF_TEXT;
   lv->iSubItem = 0;
   lv->pszText = LPSTR_TEXTCALLBACK;

   while(i > 0)
   {
      iRet = ListView_InsertItem(hList, lv);
      i--;
   }
   return TRUE;
}

//  CreateDatePick creates a DTP control within a dialog box.
//  Returns the handle to the new DTP control if successful, or NULL 
//  otherwise.
//
//    hwndMain - The handle to the main window.
//    g_hinst  - global handle to the program instance.


LRESULT APIENTRY MainProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	
   static   CREATESTRUCT   *cs;
   

   static   LV_ITEM        lv;
   static   Item           ListItem[3];
   // i caratteri in eccedenza di riga verranno eliminati
   static   char           szColumnHeader[5][12] = {"N.", "Evento", "Frequenza", "Attivo", "Iniziato il"};
   int                     index;
   int                     iiWidth[5];
   LV_COLUMN               lvC;
   RECT                    rect;

   LV_DISPINFO             *lvd;
   NMHDR                   *hdr;
  

   switch (msg)
   {
   case WM_CREATE :
	   
	  
      cs = (CREATESTRUCT *)lParam;
     
      hWndListView = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW,
         "", WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA,
         0, 0, 0, 0, hwnd,(HMENU)ID_LISTVIEW, hInstance, NULL);
	 
      ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

      iiWidth[0] = 60;
      iiWidth[1] = 600;
      iiWidth[2] = 200;
	  iiWidth[3] = 50;
      iiWidth[4] = 100;

      lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
      lvC.fmt = LVCFMT_LEFT;

      for(index = 0; index < 5; index++)
      {
         
         lvC.cx = iiWidth[index];
         lvC.pszText = szColumnHeader[index];
         ListView_InsertColumn(hWndListView,index,&lvC);
      }

      // Add some items here
	  
      strcpy(ListItem[0].szItemNr, "1");
      strcpy(ListItem[0].szItem, "Cat");
      strcpy(ListItem[0].szItemDescription, "Pet");

      strcpy(ListItem[1].szItemNr, "2");
      strcpy(ListItem[1].szItem, "Dog");
      strcpy(ListItem[1].szItemDescription, "Pet");
	  
      

      AdjustListView(hWndListView, &lv, 2);
	  
hFont = CreateFont(16, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
SendDlgItemMessage(hwnd, ID_LISTVIEW, WM_SETFONT, (WPARAM)hFont, TRUE);
edit = CreateWindow("Button","Add",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,28,515,80,33,hwnd,(HMENU)NUOVO,g_hInst,0);
add = CreateWindow("Button","Edit",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,132,515,80,33,hwnd,(HMENU)MODIFICA,g_hInst,0);

 
      break;
	  

   case WM_SIZE :
	   

      GetClientRect(hwnd, &rect);
      MoveWindow(hWndListView, 3, 3, rect.right, rect.bottom - 70, 1);
      break;

	  case WM_COMMAND :
		  
		  switch(LOWORD(wParam)) {
	  case NUOVO:
			ShowWindow(other,SW_SHOW);
			SetWindowText(hwndED, "");
			SetWindowText(other, "Aggiungi promemoria");
		  break;
	  case MODIFICA:
		  ShowWindow(other,SW_SHOW);
		  index = SendMessage(hWndListView,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
			SetWindowText(other, "Modifica promemoria");
		  SetWindowText(hwndED, ListItem[index].szItem);
		  break;
		
		  }
		 break; 
	  
	  
		  

   case WM_NOTIFY :
      switch(((LPNMHDR)lParam)->code)
      {
      case NM_DBLCLK :
         hdr = (NMHDR FAR*)lParam;
         if(hdr->hwndFrom == hWndListView)
         {
            index = ListView_GetNextItem(hWndListView,-1,LVNI_SELECTED);
            if(index != -1)
            {
               MessageBox(hwnd, ListItem[index].szItem, "Doubleclicked on this item", MB_OK);
            }
         }
         break;

      case LVN_GETDISPINFO :
         lvd = (LV_DISPINFO FAR*)lParam;
         if((((LPNMHDR)lParam)->hwndFrom == hWndListView))
         {
            switch(lvd->item.iSubItem)
            {
            case 0:
               lvd->item.pszText =  ListItem[lvd->item.iItem].szItemNr;
               break;
            case 1:
               lvd->item.pszText = ListItem[lvd->item.iItem].szItem;
               break;
            case 2:
               lvd->item.pszText = ListItem[lvd->item.iItem].szItemDescription;
               break;
            }
            break;
         }
      }
      break;
	  
   case WM_CLOSE :
      DestroyWindow(hwnd);
      break;

   case WM_DESTROY :
      DeleteObject(hFont);
      PostQuitMessage(0);
      break;
   }
   return DefWindowProc(hwnd, msg, wParam, lParam);
}

// winmain entry point


// Other Window CallBack Function
LRESULT APIENTRY OtherProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
CREATESTRUCT      *cs;
static SYSTEMTIME st;
static HWND       hWndStartDate, hWndStartTime;
static char       szDate[15], szTime[10], szStamp[20];
NMDATETIMECHANGE  *Date;
const TCHAR *items[] = { TEXT("Ogni anno"), TEXT("Ogni mese"),TEXT("Ogni settimana"), TEXT("Ogni giorno"), TEXT("Una volta") };
int i;
  long Lresult;

  switch(msg)  
  {
      case WM_CREATE:
		  

      
            hwndCombo = CreateWindow(TEXT("combobox"), NULL, 
                  WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
                  177, 216, 216, 110, hwnd, NULL, g_hInst, NULL); 

CreateWindow(TEXT("button"), TEXT("Dettagli promemoria"), 
       WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
       12, 52, 899, 97, hwnd, (HMENU) 0, g_hInst, NULL);
CreateWindow(TEXT("button"), TEXT("Giorno e ora"), 
       WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
       16, 176, 644, 184, hwnd, (HMENU) 0, g_hInst, NULL);
hwndED=CreateWindowEx(WS_EX_CLIENTEDGE,"edit", "",
WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
251, 90, 606, 24, hwnd, (HMENU)nEditID, g_hInst, NULL);

hWndStartDate = CreateWindowEx(0, DATETIMEPICK_CLASS, NULL,
         WS_BORDER | WS_CHILD | WS_VISIBLE,
         177,261,220,25,
         hwnd, NULL, 
		 
		 
		 
		 
		 
		 hInstance, NULL);
SendMessage(hWndStartDate, WM_SETFONT, (WPARAM)hFont, FALSE);
hWndStartTime = CreateWindowEx(0, DATETIMEPICK_CLASS, NULL,
         WS_BORDER | WS_CHILD | WS_VISIBLE | DTS_TIMEFORMAT,
         177,307,220,25,
         hwnd, NULL, 
		 hInstance, NULL);
SendMessage(hWndStartTime, WM_SETFONT, (WPARAM)hFont, FALSE);							 



for ( i = 0; i < 5; i++ ) {
	
                SendMessage(hwndCombo, CB_INSERTSTRING, 0, (LPARAM) items[i]);
            }
HWND save;
HWND cancel;
save = CreateWindow("Button","Save",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,28,515,80,33,hwnd,(HMENU)SAVE,g_hInst,0);
cancel = CreateWindow("Button","Cancel",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,132,515,80,33,hwnd,(HMENU)CANCEL,g_hInst,0);

break;

case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT);


TextOut(hdc, 41, 90, "Nome promemoria", strlen("Nome promemoria"));
TextOut(hdc, 41, 216, "Periodo", strlen("Periodo"));
TextOut(hdc, 41, 261, "Data evento", strlen("Data evento"));
TextOut(hdc, 41, 307, "Ora evento", strlen("Ora evento"));
EndPaint(hwnd, &ps);


break;
    case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case SAVE:
			
		IL CODICE DOVREBBE ANDARE QUI
	
		
        break;
		}
		break;

	case WM_CLOSE:
		ShowWindow(hwnd,SW_HIDE);
		break;
	default: return DefWindowProc(hwnd,msg,wParam,lParam);
	}

	return 0;
}


// initlize application

int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR line,int CmdShow)
{
	MSG msg;
	
	InitApp(hInst);

	while(GetMessage(&msg,0,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}
Grazie

Ultima modifica di giovannigiorgio : 31-03-2010 alle 09:16.
giovannigiorgio è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Cybersecurity: email, utenti e agenti IA, la nuova visione di Proofpoint Cybersecurity: email, utenti e agenti IA, la nuo...
Hisense A85N: il ritorno all’OLED è convincente e alla portata di tutti Hisense A85N: il ritorno all’OLED è convi...
Recensione Borderlands 4, tra divertimento e problemi tecnici Recensione Borderlands 4, tra divertimento e pro...
TCL NXTPAPER 60 Ultra: lo smartphone che trasforma la lettura da digitale a naturale TCL NXTPAPER 60 Ultra: lo smartphone che trasfor...
Un fulmine sulla scrivania, Corsair Sabre v2 Pro ridefinisce la velocità nel gaming Un fulmine sulla scrivania, Corsair Sabre v2 Pro...
Arriva Logitech MX Master 4, mouse super...
Storie di Brand racconta la nascita dell...
EFF lancia l'allarme: con Chat Control l...
Il nuovo tablet 'Pro' di HONOR punter&ag...
Trasferire una eSIM TIM sul nuovo iPhone...
Torna il super notebook Lenovo con Core ...
MacBook Pro: prima un refresh e poi il s...
Mondaic, il software nato per Marte che ...
SpaceX annuncia l'undicesimo volo del ra...
CMF lancia le sue prime cuffie over-ear:...
Condannata a Londra la protagonista dell...
Addio Amazon? ChatGPT ora ti fa comprare...
YouTube chiude la causa con Trump: accor...
Avio: contratto da 40 milioni di € da ES...
Claude Sonnet 4.5, il nuovo modello di A...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 08:15.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v