|
So I think I have a long way to learn it(how many years?) if I can but I think I must try very hard if I want to understand it,and I dont think we can to learn together because chinese is your first language but I dont know even alphabet also I think it has a rule for write each character for example of right or left or up or down.
|
|
|
|
|
Hi all.
In an owner drawn list box, when I try to set the item height by ...
--------------------------------------------------------------------
void CListBoxEx::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight = m_nHeight;
}
--------------------------------------------------------------------
I have defined m_nHeight as a class memner and its of an int type. I am setting its value with the help of another function...
SetItemHeight(int nVal).
When I pass the values for m_nHeight to be greater than 255, then the values got truncated...
Eg.
1. When I passed 300, the item height was set to 300-256 = 49.
2. When I passed 400, the item height was set to 400-256 = 149.
etc.
I have taken care to set the proper data types for m_nHeight, and data type of lpMeasureItemStruct->itemHeight is UINT. Then what could be the reason behind this value truncation?
Thanks
Sameer Thakur
|
|
|
|
|
from MSDN [^]:
The maximum height of a list box item is 255.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
And is there any way to overwrite this limitation?
|
|
|
|
|
i have to find the mozila installed or not in a system.How i find that in registry editor.Which mfc class help for this. plz help me.
|
|
|
|
|
Try CRegKey
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
prathuraj wrote: i have to find the mozila installed or not in a system.How i find that
I assume you want to know whether Firefox is installed or not and I suggest the following if this is the case:
1. open the "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox " key in the registry.
2. Read the contents of the "CurrentVersion " value, they wil be used in the next step.
3. Open the key "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox <CurrentVersion contents from #2>\Main " and read the contents of the "PathToExe " value.
4. Verify that the exe-file exists where it's supposed to.
If everything worked and you could find the exe-file, you have verified that Firefox is properly installed.
If any key is missing, or could not be opened, then you can assume that Firefox is not properly installed.
At first, have a look with the registry editor to see how the keys and values are organized.
As for how to do deal with the registry from your code, I suggest you have a look in the "Registry" section among the articles here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
We have a bug in our project, the problem is:
There is a group box and inside the group box there are 2 radio buttons, all the three controls have mnemonics. When I give the shortcut for group box the focus shifts to the first radio button (because that’s the first control with tab stop) but when I give the short cuts for the 2 radio buttons, the focus shifts from one button to the other but the radio buttons remain unchecked. That is, which ever button is checked by default remains checked even when I give the shortcut for the other radio button but the focus is shifted.
I proposed a solution to this by overriding the PreTranslateMessage() function and capturing the 2 shortcuts for the radio buttons and checking the appropriate radio buttons programmatically and un-checking the other radio button using CWnd::CheckDialogButton() function.
However I couldn’t find the cause for this bug, I checked the Group and Tab Stop properties of the controls and tried changing these properties but still the mnemonics don’t work.
I was wondering if anyone faced this problem before?!! Or if there’s a better way to fix this bug?!!
Thanks,
swathi
|
|
|
|
|
Hi
I’m creating one windows service in my own purpose
Using msxml4.dll.
The process of service is to fetch the data from exchange server through webdav SEARCH METHOD
When i use this coding in windows form normal button click event , it works fine,
When I convert into windows service, it throws the error
The coding is below
MSXML2.XMLHTTP objXMLHTTP = new MSXML2.XMLHTTP();
writemethod("After Initialize");
System.Xml.XmlDataDocument xmlDOMParams = new System.Xml.XmlDataDocument();
objXMLHTTP.open("SEARCH", strInboxURL,false,strAliasName, strPassword);
objXMLHTTP.setRequestHeader("Content-type", "text/xml");
objXMLHTTP.setRequestHeader("Depth", "1");
string strXML;
strXML = "" +
"<d:searchrequest xmlns ="\'DAV:\'">" +
"<d:sql>" +
"SELECT \"urn:schemas:httpmail:fromemail\"," +
------------------
---------etc…
objXMLHTTP.send(strXML); // Error Raised
The Error Raised in when i send the xml query
Any suggestion,please reply
We are using c#
Regards,
Arunkumar S
|
|
|
|
|
ArunkumarSundaravelu wrote: We are using c#
No habla C#
Translation: Wrong forum
|
|
|
|
|
I use CImage class for working with bitmaps and noticed memory leak and can't understand the problem.
When i'm trying to change the content of bitmap by accessing the bytes - in different cases i see or not see memory leaks, however the code is same!
Here is the code:
<br />
UINT __cdecl CGNTGDALDlg::GNTClassificationFunction( LPVOID pParam )<br />
{<br />
ThreadStruct* pStruct = (ThreadStruct*)pParam;<br />
int n = pStruct->pDlg->m_Image.GetHeight();<br />
int m = pStruct->pDlg->m_Image.GetWidth();<br />
int LineLength = pStruct->pDlg->m_Image.GetPitch();<br />
unsigned char* Bitmap = (unsigned char*)pStruct->pDlg->m_Image.GetBits();<br />
Bitmap+=LineLength*pStruct->Offset;<br />
if(pStruct->pDlg->m_floatingWindowSize==0)<br />
{<br />
__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);<br />
for(int i =pStruct->Offset;i<pStruct->End;i++)<br />
{<br />
for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)<br />
{<br />
double distance;<br />
CGNTNeuron* pNeuron;<br />
double Norm = 0;<br />
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
{<br />
pInputs[k] = pStruct->pDlg->m_pImageMatrix[k][i][m-l-1];<br />
Norm+=pInputs[k];<br />
}<br />
Norm = sqrt(Norm);<br />
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
pInputs[k]/=Norm;<br />
EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
unsigned int value = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron); <br />
LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
<br />
*(Bitmap-LineLength-j-1) = GetRValue(value);
*(Bitmap-LineLength-j-2) = GetGValue(value);
*(Bitmap-LineLength-j-3) = GetBValue(value);
}<br />
Bitmap+=LineLength;<br />
}<br />
_aligned_free(pInputs);<br />
}<br />
else<br />
{<br />
__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);<br />
for(int i =pStruct->Offset;i<pStruct->End;i++)<br />
{<br />
if(i<pStruct->pDlg->m_poDataset->GetRasterYSize()-pStruct->pDlg->m_floatingWindowSize)<br />
for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)<br />
{<br />
if(l<pStruct->pDlg->m_poDataset->GetRasterXSize()-pStruct->pDlg->m_floatingWindowSize)<br />
{<br />
double distance;<br />
CGNTNeuron* pNeuron;<br />
int ll = 0;<br />
double Norm = 0;<br />
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
for(int ii = i;ii<i+pStruct->pDlg->m_floatingWindowSize;ii++)<br />
for(int jj = l;jj<l+pStruct->pDlg->m_floatingWindowSize;jj++)<br />
{<br />
pInputs[ll++] = pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];<br />
Norm+=pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1]*pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];<br />
}<br />
Norm = sqrt(Norm);<br />
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount()*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize;k++)<br />
pInputs[k]/=Norm;<br />
EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
unsigned int Value = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron); <br />
LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
*(Bitmap-LineLength-j-1) = GetRValue(Value);
*(Bitmap-LineLength-j-2) = GetGValue(Value);
*(Bitmap-LineLength-j-3) = GetBValue(Value);
<br />
}<br />
}<br />
Bitmap+=LineLength;<br />
}<br />
_aligned_free(pInputs);<br />
}<br />
return 0;<br />
}<br />
<br />
|
|
|
|
|
I'll try to help but I can't read your posted code.
Can you wrap it in "pre" tags instead of "code" tags?
How do you know there's a leak? How are you checking?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well, i looked in the task manager - when this process is running the momory grows up.
Here is code in pre tags
UINT __cdecl CGNTGDALDlg::GNTClassificationFunction( LPVOID pParam )
{
ThreadStruct* pStruct = (ThreadStruct*)pParam;
int n = pStruct->pDlg->m_Image.GetHeight();
int m = pStruct->pDlg->m_Image.GetWidth();
int LineLength = pStruct->pDlg->m_Image.GetPitch();
unsigned char* Bitmap = (unsigned char*)pStruct->pDlg->m_Image.GetBits();
Bitmap+=LineLength*pStruct->Offset;
if(pStruct->pDlg->m_floatingWindowSize==0)
{
__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);
for(int i =pStruct->Offset;i<pStruct->End;i++)
{
for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)
{
double distance;
CGNTNeuron* pNeuron;
double Norm = 0;
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)
{
pInputs[k] = pStruct->pDlg->m_pImageMatrix[k][i][m-l-1];
Norm+=pInputs[k];
}
Norm = sqrt(Norm);
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)
pInputs[k]/=Norm;
EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);
unsigned int value = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron);
LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);
*(Bitmap-LineLength-j-1) = GetRValue(value);
*(Bitmap-LineLength-j-2) = GetGValue(value);
*(Bitmap-LineLength-j-3) = GetBValue(value);
}
Bitmap+=LineLength;
}
_aligned_free(pInputs);
}
else
{
__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);
for(int i =pStruct->Offset;i<pStruct->End;i++)
{
if(i<pStruct->pDlg->m_poDataset->GetRasterYSize()-pStruct->pDlg->m_floatingWindowSize)
for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)
{
if(l<pStruct->pDlg->m_poDataset->GetRasterXSize()-pStruct->pDlg->m_floatingWindowSize)
{
double distance;
CGNTNeuron* pNeuron;
int ll = 0;
double Norm = 0;
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)
for(int ii = i;ii<i+pStruct->pDlg->m_floatingWindowSize;ii++)
for(int jj = l;jj<l+pStruct->pDlg->m_floatingWindowSize;jj++)
{
pInputs[ll++] = pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];
Norm+=pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1]*pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];
}
Norm = sqrt(Norm);
for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount()*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize;k++)
pInputs[k]/=Norm;
EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);
unsigned int Value = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron);
LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);
*(Bitmap-LineLength-j-1) = GetRValue(Value);
*(Bitmap-LineLength-j-2) = GetGValue(Value);
*(Bitmap-LineLength-j-3) = GetBValue(Value);
}
}
Bitmap+=LineLength;
}
_aligned_free(pInputs);
}
return 0;
}
|
|
|
|
|
As long as you are freeing memory you allocate you should be fine.
The task manager isn't always a great leak detector. Memory allocated for your process may
be marked as available to the application but not freed until it's necessary - for performance.
Trust your code
The debug C runtime (CRT) will show leaks at runtime for malloc, _aligned_malloc, new, etc.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Ok! Thank You very much for participating.
|
|
|
|
|
hi,
I am using the following code to send a string to the notepad, without direct keyboard input(using SendInput function):
//start of code
CString str(_T("D:\\sample.gho"));
INPUT key[2];
int nLeng = str.GetLength();
for(int index=0;index < nLeng;index++ )
{
::ZeroMemory(key, sizeof(key));
key[0].type = key[1].type = INPUT_KEYBOARD;
SHORT nKeyCode = VkKeyScan(str[index]);
if (VK_SHIFT & nKeyCode)
{
key[0].ki.wVk = VK_SHIFT;
key[0].ki.dwFlags = KEYEVENTF_KEYUP;
//shift key plus char
key[1].ki.wScan = str[index];
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
else if (VK_CAPITAL & nKeyCode)
{
key[0].ki.wVk = VK_CAPITAL;
key[0].ki.dwFlags = KEYEVENTF_KEYUP;
//capital key plus char
key[1].ki.wScan = str[index];
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
else
{
key[1].ki.wVk = nKeyCode;
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
key[0].ki.time = key[1].ki.time = 0;
key[0].ki.dwExtraInfo = key[1].ki.dwExtraInfo=0;
SendInput(2,key,sizeof(INPUT));
}
//end of code
But, unfortunately, I gets an error:
'KEYEVENTF_UNICODE' : undeclared identifier
Please help me.
Thanks in advance.
SYAMLAL
|
|
|
|
|
MSDN say, that KEYEVENTF_UNICODE used for Windows 2000/XP only.
In winuser.h you can see
#if(_WIN32_WINNT >= 0x0500)
#define KEYEVENTF_UNICODE 0x0004
#define KEYEVENTF_SCANCODE 0x0008
#endif /* _WIN32_WINNT >= 0x0500 */
So, if you are realy in Win2000 or XP...
Look in file stdafx.h.
I work in XP, and I have next line in stdafx.h :
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
See? Change this on
#define _WIN32_WINNT 0x0500
#endif
May be it'll help for you
Best regards,
Baron
|
|
|
|
|
Thanks a lot.
Actually
#define KEYEVENTF_UNICODE 0x0004
#define KEYEVENTF_SCANCODE 0x0008
these lines were not present in my winuser.h file.
So I added these in that file, and the application is now working fine.
Once again,,thanx
SYAMLAL
|
|
|
|
|
hi my project is obut proming with port usb .plz explain obut it.tanks
|
|
|
|
|
Click here[^]
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
I have a text file which its contents in has to be loaded into an array. The content in the.txt file has some spaces between them and it is also a few lines long(separated by '\n'). May i know how to copy the whole file into an array?
Thank you for any help.
|
|
|
|
|
i'd suggest you to turn to C++ solutions instead of sticking to C.
by the way :
char pszBuffer[NUMBER_LONG_ENOUGH];
::fscanf(myOpenedFile, "%s", pszBuffer);
|
|
|
|
|
I can't use this method, somehow the character save in the file turns out to be in funny shapes and not the ones i input. Below is the code i used.
FILE *stream;
stream = fopen( "Result File.txt", "w+" );
char pszBuffer[500]; ::fscanf(stream, "%s", pszBuffer);
|
|
|
|
|
hey, you open the file writable, not readable...
|
|
|
|