|
I do this @ doubleclick event:
<br />
LVITEM lvi;<br />
int nimage;<br />
int nitem;<br />
nitem=m_ctlServerList.GetSelectionMark();<br />
m_ctlServerList.GetItem(&lvi);<br />
nimage=lvi.iImage;<br />
The Problem is lvi.iImage returns always 0.
|
|
|
|
|
Couple of comments:- You should intialize
lvi to zero to ensure the code works correctly in release mode.
- You need to do
lvi.mask = LVIF_IMAGE; before calling GetItem() . Hope this helps!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yeah it works fine! thx!
I got a new problem. I Fill a list control with stuff which is todo, i call it todolist.
The size of the ctrl displays 3 items without scrolling (item count varies).
I want to scroll to the current proccess item.
I´ve tried alot but didnt get any good result.
Here´s a code snipped:
<br />
m_nTodoItem=nitem;<br />
m_pCtlListTodo->GetItemRect(0,rect,LVIR_ICON);<br />
size.cy=0;<br />
size.cy=nitem * rect.Height();<br />
m_pCtlListTodo->SetScrollPos(SB_VERT,0);<br />
m_pCtlListTodo->Scroll(size);<br />
<br />
m_pCtlListTodo->Scroll(size);<br />
m_pCtlListTodo->SetSelectionMark(nitem);<br />
Sometimes just the bars scroll without the content.
How to scroll dynamicly with considering user actions.
Thx alot for help and sorry for bad english.
|
|
|
|
|
shibble wrote:
I want to scroll to the current proccess item.
Assuming you know the index of the item, you can call CListCtrl::EnsureVisible() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Great,great,great!!!!!
3 Hours of testing with those cra** scrollbars, its just one function..
Thx alot!!!!!!!!!
|
|
|
|
|
Hi,
I have never worked on passing arguments to a cpp file. I am trying to pass a file name as an argument to the program and then return an 2Darray of data. becos i want to call this exe from from an external program.
can anyone help me by giving a prototype syntax for accomplishin this task.
thanks in advance,
Suman
|
|
|
|
|
See this[^] article. Your app should probably write its output to a (user specified) file.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Anyway, my teacher wants us to have an array size of 1,000,000(1 million) and have a segment size of 10000. However, if i put my segment size at 300000 or greater, i get an error saying that the program has encountered an error and needs to close. I can do 100000 and 200000 but anything greater and I get that error.
The programs works fine on 100000 and 200000 it sorts the thread correctly in bubble and multithread sort.
EDIT: For some reason i cant put the code in php.
Here is the code:
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
const int ArraySize=300000;
const int SegmentSize=10000;
const int SleepInterval=10;
DWORD WINAPI SortFun(LPVOID);
void InitializeArray(void);
void Merge(void);
int FindMinKeys(int keys[]);
void DisplayArray(int begin, int end);
void SORT(void);
static int RunFlag = ArraySize/SegmentSize;
int Array[ArraySize];
clock_t start, finish;
double duration;
LPSECURITY_ATTRIBUTES lpthreadattributes = NULL;
DWORD stacksize = 0;
DWORD dwcreationflags;
DWORD ThreadId[ArraySize/SegmentSize];
HANDLE TargetThread[ArraySize/SegmentSize];
void main(void)
{
InitializeArray();
start = clock();
// SORT();
finish = clock();
printf("\n Array Size =%d \n Segment Size =%d \nSleep Interval =%d\n",
ArraySize, SegmentSize, SleepInterval);
printf("\n ***** elapsed time for Single_threaded Bubble sort ****");
duration = (double)(finish - start) / CLOCKS_PER_SEC; // elapsed time in clocks/second
printf("\n clock ticks = %10.3lf\n",(double)(finish-start)); // elapsed time, clock ticks
printf("\n seconds = %10.3lf\n", duration );
// char ch=getchar();
// DisplayArray(0,ArraySize-1);
// ch = getchar();
// Create threads to sort every 1000 th segment of the array
int j=0;
start = clock();
for (int i=0; i<ArraySize; i=i+SegmentSize)
{
TargetThread[j] =
CreateThread(
NULL,
0,
SortFun,
&i,
0,
&ThreadId[j]
);
// printf(" j= %d th thread created\n",j);
//char ch = getchar();
// give time to the newly created thread to work
Sleep(SleepInterval);
// create the next thread
j++;
}
// wait for all threads to complete their work
while (RunFlag > 0)
Sleep(SleepInterval);
// Merge the sorted arrays
Merge();
finish = clock();
printf(" The Entire Array Sorted\n");
printf("\n ***** elapsed time for Multi_threaded Bubble sort ****");
printf("\n ***** Segment Size ***** %d\n",SegmentSize);
duration = (double)(finish - start) / CLOCKS_PER_SEC; // elapsed time in clocks/second
printf("\n clock ticks = %10.3lf\n",(double)(finish-start)); // elapsed time, clock ticks
printf("\n seconds = %10.3lf\n", duration );
// ch=getchar();
// DisplayArray (0,ArraySize-1);
// ch = getchar();
}
void InitializeArray(void)
{
for (int i=0; i<ArraySize; i++)
Array[i] = (rand()*171+rand())%1000000U;
}
void SORT(void)
{
int exchange;
int low = 0;
int high = ArraySize;
// printf(" low = %d high = %d\n",low,high);
for (int k = low; k<high-1; k++)
{
exchange = 0;
for (int l = low; l<= low +high-(k+1); l++)
if (Array[l] > Array[l+1])
{
int t = Array[l];
Array[l] = Array[l+1];
Array[l+1] = t;
exchange = 1;
}
if (exchange == 0) break;
}
}
DWORD WINAPI SortFun(LPVOID N)
{
int exchange;
int low = *(int*)N;
int high = low + SegmentSize-1;
// sort that portion of the array
// printf(" low = %d high = %d\n",low,high);
for (int k = low; k<high-1; k++)
{
exchange = 0;
for (int l = low; l<= low +high-(k+1); l++)
if (Array[l] > Array[l+1])
{
int t = Array[l];
Array[l] = Array[l+1];
Array[l+1] = t;
exchange = 1;
}
if (exchange == 0) break;
}
RunFlag--;
// printf(" ****** Array Segment Sorted ******\n");
//DisplayArray(low,low+SegmentSize-1);
// printf(" i= %d th tread ended\n",low/SegmentSize);
// char ch = getchar();
CloseHandle((void *)&TargetThread[low/1000]);
return 0;
}
void Merge(void)
{
int t[ArraySize];
int p[ArraySize/SegmentSize];
int keys[ArraySize/SegmentSize];
// set the pointers to point to the begining of the sorted segments
for (int i=0; i<ArraySize/SegmentSize; i++)
{
p[i] = i*SegmentSize;
keys[i] = Array[p[i]];
}
// Merge the Array portions
int tposition = 0;;
int Done = 0;
int MinPosition;
while (! Done)
{
MinPosition = FindMinKeys(keys);
if (MinPosition != -1)
{
t[tposition] = Array[p[MinPosition]];
tposition++;
p[MinPosition]++;
if (p[MinPosition] % SegmentSize == 0)
{
// reached the end of one segment
keys[MinPosition] = 1000000U;
}
else
keys[MinPosition] = Array[p[MinPosition]];
}
else
Done =1;
}
for (int j=0; j<ArraySize; j++)
Array[j] = t[j];
}
int FindMinKeys(int keys[])
{
int position = 0;
for (int i = 1; i<ArraySize/SegmentSize; i++)
{
if (keys[i] < keys[position])
position = i;
}
if (keys[position] == 1000000U) return -1;
return position;
}
void DisplayArray(int begin, int end)
{
for (int j=begin; j<=end; j++)
{
printf("%6d Array[i] = %6d \n",j,Array[j]);
}
}
|
|
|
|
|
I am writing my first test C++ .Net program. A simple DLL and a program to call it. The DLL opens up a dialog upon request and displays passed parameters. Both the DLL and the Calling programs are Projects in a Solution.
So far, everything works, expect for the DLL opening the model dialog. I suspect I am not copying the correct information over to the caller directory.
In the property pages of the DLL, I specify two copy statements one to copy the .lib to the caller apps “debug” folder and the other to copy the .dll. (I know I should create my own lib folders somewhere and copy all to those, but this is a test)
This allows the caller app to link and load the dll at execution time, but the does not display the dialog. What am I missing? I have tried copying the .ddl’s .res (compiled resource) to the caller apps ‘Debug” folder, but that didn’t work.
Should I be bringing something else over, or do I need to set an alternative runtime path?
Thanks for your help
Phil
|
|
|
|
|
I have just decided to write my first GUI system and I was wondering if any of you might know of some good reading material or tutorials for getting started with writing and event system
thanks
hair today gone tomorrow
|
|
|
|
|
Hello,
I started to learn Visual C++ a week ago. I used to code in BCB before, a bit on ASM & WinAPI.
At the moment, the main problem for me is creating a GUI. After BCB, creating GUI in VC++ programs seems very difficult and not effectively.
So I have a few questions to you.
1) When I use CFrameWnd object as a main form, and place my controls on it - it flashes when I resize the form.
People adviced me to use WS_CLIPSIBLINGS & WS_CLIPCHILDREN styles and it partially helped.
All controls except Static and Tab Control (CTabCtrl) stopped flashing. Static flashes a bit and Tab Control flashes much. It's like I have a very slow computer =) But it's not true of course.
I have created a small example for u. All u need is compile it and try to resize and u will see that Tab Control flashes hard.
Do you know how to fix it?
2) Another question is: How can I handle right mouse click.
For example I have a static control on my form and I want to show a messagebox when a user clicks right mouse button on it. How can I do this?
I hope you help me guys. Thank you very much for spending your time reading this. Please, help me.
|
|
|
|
|
Oh, I fogot...
You can download my test example (that shows flashing) here: http://MozgC.info/test.zip
|
|
|
|
|
your are not using MFC.
file --> new --> project --> visual c++ project --> mfc --> mfc aplication.
choose aplication type ...
choose dialog
after creating a new project
go to recource explorer and click on dialog
and draw your control and they don't flikker or flash
i think u choose win32 project.
kind regards,
marco
Bad = knowing 2 much
|
|
|
|
|
I am not using MFC? =)
Have u seen my test example?
class CMyWnd : public CFrameWnd
{
public:
CMyWnd(char *Title);
~CMyWnd();
private:
CStatic *Label;
CButton *Button;
CStatusBar *StatusBar;
CEdit *Edit;
CTabCtrl *TabControl;
};
Aren't these MFC classes? =)
As for mfc application -> Dialog based - Of course it will not flash - Dialog can not be resized, and I said that it flashes on resizing...
Any other ideas?
|
|
|
|
|
here are some nice program for to study.
www.pablovandermeer.nl
1 project is about resizing dialogs
kind regards,
marco
Bad = knowing 2 much
|
|
|
|
|
Anyone out there with good edge linking algorithm in visual c++. Usually , using edge detector will produce broken edges or false edges. i need an algorith or sourcecode that will link up all the broken edges especially the broken edges of an outerboundary object.
Anyone with source code is greatly appreciated? anyone plx help me out here.
|
|
|
|
|
I have a dll that is kicked off by a number of processes. I have identified which one but when I run it in msvs6.0 I get a stack exception before it activates any of my debug points which are at the beginning of each entry routine. All I get is an assembled view of the exception with an offset address into the dll. When I look at the call trace it just shows the same offset but doesn't show what entry was called. Is there anyway to know the address of each entry point? How do I get where the exception is occurring within the code without it being so cryptic? I know it is not a bad parm because all the parms are passed by the calling process. These are the exact same parms passed by the other processes that work. I can even suspect which entry point is being called but I don't see anything in there that would cause a problem. The code was written in c and runs on multiple platforms but only fails on windows.
|
|
|
|
|
Have you tried to set a breakpoint in DllMain?
|
|
|
|
|
HI
I have a memory leak in my programm. I have tried hard but not been able to solve it. I m putting the whole code that is causing memory leak. Can you show me some idea where is the possibility of memory leak.????
My code goes here....
------------------------------------------
// File matools.cpp
typedef unsigned char Byte;
typedef unsigned int uInt;
typedef unsigned long uLong;
int CompressData (char* sIn, char* sKey, char** sOut, long* lOutlen)
{
Byte *compr, *uncompr;
uLong comprLen = 16384*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0])
return -1;
compr = (Byte*) new uInt[comprLen];
uncompr = (Byte*) new uInt[uncomprLen];
//End lines by Mahesh
if (compr == Z_NULL || uncompr == Z_NULL)
{
// Line added by Mahesh
//What if compr is NULL and uncompr is not NULL....no indication for it....
delete [] compr; //free(compr);
delete [] uncompr; //free(uncompr);
// End of line added by Mahesh
return -2;
}
uncomprLen = strlen (sIn);
int iResult = test_compress(compr, &comprLen, (Bytef*)sIn, uncomprLen);
if (iResult != 0)
{
// Line added by Mahesh
//What if compr is NULL and uncompr is not NULL....no indication for it....
uncomprLen = 0;
delete [] compr; //free(compr);
delete [] uncompr; //free(uncompr);
// End of line added by Mahesh
return -3;
}
byte *buffer, key[32];
unsigned int bufLen;
unsigned int err;
ailaes demo;
char s2[33] = "";
int len = strlen(sKey);
if (len > 64)
len = 64;
for (int i = 0, j = 0; i < len; i ++, j ++)
{
char sTemp[2] = "";
sTemp[0] = sKey[i];
sTemp[1] = 0;
int c = 0;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c = atol(sTemp) * 16;
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c = 10 * 16;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c = 11 * 16;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c = 12 * 16;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c = 13 * 16;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c = 14 * 16;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c = 15 * 16;
sTemp[0] = sKey[i + 1];
sTemp[1] = 0;
i ++;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c += atol(sTemp);
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c += 10;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c += 11;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c += 12;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c += 13;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c += 14;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c += 15;
s2[j] = c;
}
s2[j] = 0;
// pad out the input string to be an even block size
// Line Added My Mahesh Amarelia 02/09/04
// Memory allocated to the variable "*b" in strToBlock() has not been freed...
err = demo.strToBlock((char*)compr, comprLen, &buffer, &bufLen);
memmove(key, s2, 32);
demo.init(CBC, key);
// encript the buffer
err = demo.encrypt(buffer, bufLen);
if (err != 0)
{
// Line added by Mahesh
//What if compr is NULL and uncompr is not NULL....no indication for it....
uncomprLen = 0;
free (buffer);
delete [] compr; //free(compr);
delete [] uncompr; //free(uncompr);
// End of line added by Mahesh
return -4;
}
// encode the crypto buffer so it can pass as a null terminated string
*sOut = ESCencode( (char*)buffer, bufLen);
*lOutlen = strlen(*sOut);
//Lines added by Mahesh
delete [] buffer;
delete [] compr;
delete [] uncompr;
buffer = NULL;
compr = NULL;
uncompr = NULL;
return 1;
}
static char* ESCencode(char* sIn, long sLen)
{
char* sOut, *s;
long i,j, len, grow;
char c;
// determine len of encoded str
len = sLen;
for(i=0, s=sIn, grow=0; i<len; i++, s++)
if(*s == ESC || *s == ZERO || *s == 0x0d) //<<< new stuff here
grow++;
// len += (2 * grow);
len += grow;
// <AES_Encode> </AES_Encode>
/*****************************************/
/********* this is line number 309 ******/
sOut = new char[len + 1 + 25]; // Here sOut is not been freed after allocating memory
sOut[0] = '<';
sOut[1] = 'A';
sOut[2] = 'E';
sOut[3] = 'S';
sOut[4] = '_';
sOut[5] = 'E';
sOut[6] = 'n';
sOut[7] = 'c';
sOut[8] = 'o';
sOut[9] = 'd';
sOut[10] = 'e';
sOut[11] = '>';
for(i=0, j=12; j<(len + 12); i++)
switch(c = sIn[i]){
case NULL:
sOut[j++] = ZERO;
break;
case 0x0d: //<<< new stuff here
sOut[j++] = ESC;
sOut[j++] = mCR;
break;
case ZERO:
case ESC:
///Insert:
sOut[j++] = ESC;
// fall thru intended
default:
sOut[j++] = c;
break;
}
sOut[j++] = '<';
sOut[j++] = '/';
sOut[j++] = 'A';
sOut[j++] = 'E';
sOut[j++] = 'S';
sOut[j++] = '_';
sOut[j++] = 'E';
sOut[j++] = 'n';
sOut[j++] = 'c';
sOut[j++] = 'o';
sOut[j++] = 'd';
sOut[j++] = 'e';
sOut[j++] = '>';
// make sure it is null terminated
sOut[j++] = NULL;
return sOut;
}
The output that I get I use _CrtDumpMemoryLeaks() functions is as following :
-----------------------------------------------------------------------------
Detected memory leaks!
Dumping objects ->
c:\temp\matools\matools.cpp(310) : {58} normal block at 0x009F0530, 1095 bytes long.
Data: <<AES_Encode>j[L > 3C 41 45 53 5F 45 6E 63 6F 64 65 3E 6A 5B 4C F9
{46} normal block at 0x00861E20, 33 bytes long.
Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD
{45} normal block at 0x00861E70, 40 bytes long.
Data: < K > D0 10 4B 00 19 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
--------------------
Mike
|
|
|
|
|
c:\temp\matools\matools.cpp(310)
what is at this line number. Are you creating an object that you should be deleting later?
Also, make sure you are not corrupting memory or the stack in one of you loops. Check for boundary conditions.
|
|
|
|
|
Hello Sir
Thankx for taking time for my problem.
I have already written what is the line number 310 by comment...Still I am writing this again here....For whole code you can just look it back to my problem on Codeproject at http://www.codeproject.com/script/comments/forums.asp?msg=960928&forumid=1647#xx960928xx
Line number 310 and onwards....
------------------------------
sOut = new char[len + 1 + 25]; // Here sOut is not been freed after allocating memory
sOut[0] = '<';
sOut[1] = 'A';
sOut[2] = 'E';
sOut[3] = 'S';
sOut[4] = '_';
sOut[5] = 'E';
sOut[6] = 'n';
sOut[7] = 'c';
sOut[8] = 'o';
sOut[9] = 'd';
sOut[10] = 'e';
sOut[11] = '>';
.
.
.
Regards
Mahesh
|
|
|
|
|
As your procedure returns the sOut char * pointer, its now the responsibility of the callee to delete the memory. TYpically what you are doing here is bad practice as you have to remember to delete it. If you returned an std::vector<char> then if it was not used its desturctore would be called and it would delete itself thus avoiding the leak problem.
std::vector<char> sOut;
sOut.resize(len + 1 + 25);
...
return sOut;
If you vote me down, my score will only get lower
|
|
|
|
|
Hi
I have developed one simple DLL in VC++ as Project->New->Win32 Dynamic Link Library->An empty DLL project......
Now there is some Memory Leak in my DLL. But I don't know how to trace it and which functions or line is making memory leak.
All the programm to find Memory Leak I found is for EXE only....
So someone suggested me to go for IBM's Rational Purify Evaluation for windows. I use Windows 2000 Professional as OS. I downloaded it but it is asking for Licence Key ...and I am not able to go ahead from here....any suggestion please....Or any other software such as this...?
Pls help me out
Regards
Mahesh
|
|
|
|
|
Hi,
Usually what they'll do is they'll send a licence key 2 your email id after download itself. So check @ their site itself or drop a mail to their support division.They will surely help you.
Sujan
|
|
|
|
|
Das ist super hier! leider auf englich, weiss jemand von einer deutchen variante?
LG
Gregor
|
|
|
|
|