|
Thank you for answer ... looking through MSDN , I found SubItemHitTest(...) method , but I don't know how I should use it in double click handler ...
|
|
|
|
|
I did it .. and for those who have the same issue , I put here the sample code :
void CMyView::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
CString sTemp;
LVHITTESTINFO lv;
int nItem,nSubItem;
DWORD dwPos = ::GetMessagePos();
CPoint point((int)LOWORD(dwPos),(int)HIWORD(dwPos));
m_List.ScreenToClient(&point);
lv.pt = point;
m_List.SubItemHitTest(&lv);
nItem = lv.iSubItem;
nSubItem = lv.iItem;
sTemp.Format("nItem %d nSubItem %d",nItem,nSubItem);
MessageBox(sTemp);
*pResult = 0;
}
Thank you all , specially to Chris !
|
|
|
|
|
Please look up NM_DBLCLK on MSDN.
Here's how to use it:
void CXListCtrlTestDlg::OnDblClick(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMIA = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
int nItem = -1;
int nSubItem = -1;
if (pNMIA)
{
nItem = pNMIA->iItem;
nSubItem = pNMIA->iSubItem;
}
if (nItem >= 0 && nSubItem >= 0)
{
CString strText = m_List.GetItemText(nItem, nSubItem);
Log(_T("OnDblClick at (%d,%d): '%s'"), nItem, nSubItem, strText);
}
*pResult = 0;
}
Here's the message map entry:
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblClick)
|
|
|
|
|
Does function that , except one thing : nItem is always -1 ... why ?
I mention that list controls is not empty ( I load something in it ).
|
|
|
|
|
I know why nItem is always -1 , because I have LVS_SINGLESEL style ....
|
|
|
|
|
Hi all,
i writing excel file by two diffrent ways.
1. write (*.xls) excel file by odbc driver
2. write (*.xlsx) excel file using excel automation
its working fine.
i want to create heading in first line and want to format the column title text.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
Try here[^] for lots of suggestions.
I must get a clever new signature for 2011.
|
|
|
|
|
Did a quick walk through the excel type library using OLE/COM Object Viewer, fount 'Font' interface.
Get font property of Range (get range of desired cells), and modify it.
pesedo code may look like:-
Range range = excel.getRange("A2");
Font font = range.getFont();
font.putBold(TRUE);
Also found font property for 'Selection' interface too. Try these using the automation method you are using.
|
|
|
|
|
I am currently trying to copy the contents from a single dimension array to a multiple dimension array using pointer notation. I though am having problems doing so. Can someone out there show me how to program a multiple dimension array that will take from a single dimension array? Listed below is sample code that I am trying to get to work.
Code:
#include <stdio.h>
#define SIZE 5
#define SIZE2 5
#define ROWS 2
void transarr4(int *(*(arry)), int * arry2, int row); //Pointer Notation (Multiple Dimension Array)
int main(void)
{
int arr[SIZE] = {100,200,300,400,500};
int arr2[ROWS][SIZE2] = {{},{}};
int *(*(arr3)) = 0;
transarr4(arr3,arr,ROWS); //Pointer Notation (Multiple Dimension Array)
return 0;
}
//====================================================================================================
// Pointer Notation (Multi-Dimension Array)
//====================================================================================================
void transarr4(int *(*(arry)), int * arry2, int row)
{
int num = 0;
int r = 0;
int c = 0;
for(r = 0; r < row; r++)
{
for(c = 0; c < SIZE2; c++)
{
//arr[r][c] = arr2[c];
*(*(arry)) = arry2[c];
printf("%d",*(*(arry + r)+c));
printf("\n");
}
}
}
|
|
|
|
|
Are trying to transfer content of arr to arr3, right? But I am not able to see any memory allocation for arr3... You have to allocate some memory.. The way you are doing wont be safe in terms of memory pointer usage..
You can do something like this...
case 1: assigning direct pointer of arr to arr3
arr3 = new int[SIZE];
arr3[i] = &(arr[UPTO_SIZE])
case 2: copyinh content of arr to arr3
arr3 = new int[SIZE];
arr3[i] = new int[size2]
I hope you can add proper code in this logic... As we cannot complete your assignment...
|
|
|
|
|
chevu,
Thank you for your reply. I am not taking a class but doing self study to learn C. I will take your solution and walk through the logic to understand.
Thanks again.
Mike
|
|
|
|
|
And ya if you don't want to new memory allocation you can directly assign address of arr to arr3, but for that in your function your have to send address of arr3 pointer i mean &arr3 (which you have declared as int** arr3), and in function you can assign address of arr to arr3....
|
|
|
|
|
A couple of suggestions:
1. Put your code between <pre></pre> tags so it is more readable.
2. Try compiling the above and report or fix any errors you see,
I must get a clever new signature for 2011.
|
|
|
|
|
For one, transarr() does not get all the information it needs: You have a single, one-dimensional array with 5 elements, and try to transfer it into another array with ROWS rows. But you do not give an indication about the width of those rows in the parameters. The width is only given through the global symbol SIZE2. Pass SIZE2 as a parameter instead, so transarr() does not depend on a global value and can be reused for different cases.
Second, in your main program you define a two-dimensional array arr2, but you do not use it. Instead you pass another variable, arr3 to transarr - that doesn't make sense. I think your intention was to copy the members of arr into arr2, no? If so, you do not need the variable arr3, you can pass arr2 into the call of transarr(), you don't even need to change the function declaration for that.
Third, the purpose of transarr is somewhat ... unusual: In your code you copy the original array into each row, creating multiple copies of that array. Is that your intention? Also, if SIZE2 happens to be greater than SIZE, then your copy loop will run into undefined memory as it will read beyond arr. Of course at the moment nothing happens, but if you get your program to run and later change SIZE or SIZE2, you might end up with random values in your resulting array and not know where they originate from.
|
|
|
|
|
What do you want arr2 to look like when done?
+-----+-----+-----+-----+-----+
| 100 | 200 | 300 | 400 | 500 |
+-----+-----+-----+-----+-----+
| | | | | |
+-----+-----+-----+-----+-----+
or
+-----+-----+-----+-----+-----+
| | | | | |
+-----+-----+-----+-----+-----+
| 100 | 200 | 300 | 400 | 500 |
+-----+-----+-----+-----+-----+
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi All,
Is there any Data Structure library in C language available for using in an application. I am in a need of a data structure library which I can use in my RTOS application .
|
|
|
|
|
Lots of them here[^].
I must get a clever new signature for 2011.
|
|
|
|
|
Thanks for the info. But most of libraries are Open Source , Is there any Licensed Data Structure library available which you have used.
|
|
|
|
|
Sorry no; you will have to do your own evaluation to find the one that suits you.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi all
I have a problema with MDITabbedControl.
- Open multiple MDI tab screens
- Select a tab from one of them and start moving it. Drop it on the "X" thing that closes the screen from another tab
- Now move your mouse over the other tabs. As the mouse passes over the tab, the tab still captured, mouse doesn't release the capture.
I try overloading pretranslatemsg, catching the message WM_LBUTTONUP, but still happens when during a drag/drop I click on close button.
|
|
|
|
|
Hi,
We are developing an application in which for comminication to outside module we are using WinSock based sime socket approach. Our requirement is to make sure connection will always be on, so for that reason when ever we are getting disconnected or not able to connect to outside module we keep trying after every 1 minute. Our problem starts here we have observered that on every retry of socket reconnect it is leaking exact 2 windows handles, we have tried so many options but none of them are working. Following is the code that we are using right now,
bool CSocketClass::ConnectToServer(int nLineNo)
{
string strIPAddress;
int nPortNo;
SOCKET* l_ClientSocket;
int ConnectionResult;
if (nLineNo == 1)
{
m_objLine1.m_ClientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
strIPAddress = m_objLine1.m_strIPAddress;
nPortNo = m_objLine1.m_nPortNo;
l_ClientSocket = &(m_objLine1.m_ClientSocket);
}
else
{
m_objLine2.m_ClientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
strIPAddress = m_objLine2.m_strIPAddress;
nPortNo = m_objLine2.m_nPortNo;
l_ClientSocket = &(m_objLine2.m_ClientSocket);
}
if(INVALID_SOCKET == *l_ClientSocket)
{
closesocket(*l_ClientSocket);
return false;
}
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( strIPAddress.c_str() );
clientService.sin_port = htons( nPortNo );
ConnectionResult = connect( *l_ClientSocket, (SOCKADDR*) &clientService, sizeof(clientService) ) ;
if (ConnectionResult == SOCKET_ERROR)
{
if (nLineNo == 1)
{
}
else
{
}
closesocket(*l_ClientSocket);
return false;
}
else
{
}
return true;
}
Can anyone help me? Thanks in advance.
|
|
|
|
|
I don't see any problem with this code. How do you use it?
You don't need to call closesocket() if you know the socket is INVALID_SOCKET, and you can simplify your code a bit by using a pointer to m_objLine1 and m_objLine2 instead of copying all entries needed to local variables.
WhatEverType *pObjLine = (nLineNo == 1) &m_objLine1 : &m_objLine2;
if (INVALID_SOCKET == pObjLine->m_ClientSocket)
...
|
|
|
|
|
Ya those things we have added just to check whether they could help us to reduce handle leaks but it dint help us.
We also use pointer approach also but it dint help us either...
This code is being used in one of the windows service which we use to activate manually..
|
|
|
|
|
How are you determining you have a memory leak? Is the MFC mechanism reporting leaks when you end your debug session?
Are you storing MFC CObject derived classes within STL containers or vice versa? I've on occasion gotten false memory leak reports from MFC when mixing STL and MFC (when container classes are involved).
|
|
|
|
|
Hi it seems you get it wrong. I am not talking about memory leaks, leaks I am talking about handle leaks. If I open task manager and look handle count for my application it used to increased by 2 at every connect trial...
|
|
|
|