|
We have a dynamic text and we need to obtain the coordinates of the rectangle that contains the text. How can I do that? I should use the function GetTextExtent.
Sikora
|
|
|
|
|
|
Are you wanting to drag text out of a control, or drop text into a control?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Problem: i have a list (CToolTipListCtrl)
question: i want to move two or more element from a list... have you got a idea??
CODE:
void CSmartAdvertiseDlg::OnBnClickedDown()
{
if(m_cPlaylist.GetSelectedCount() == 1)
OnBnClicked(DOWN);
}
void CSmartAdvertiseDlg::OnBnClicked(int iOp)
{
POSITION Pos;
LVITEM lvi1,lvi2;
int iPos,iPeriod,iPos2,count,ret;
CString sPeriod,str1,str2;
listDataStruct *data;
lvi1.mask = LVIF_IMAGE | LVIF_TEXT;
lvi2.mask = LVIF_IMAGE | LVIF_TEXT;
if((Pos = m_cPlaylist.GetFirstSelectedItemPosition()) != NULL)
{
while(Pos)
{
iPos = m_cPlaylist.GetNextSelectedItem(Pos);
ret = sscanf(m_cPlaylist.GetItemText(iPos,2),"%d",&iPeriod);
switch (iOp)
{
case PLUS:
case MINUS:
if(ret == 1)
{
if(iOp == PLUS)
{
if(iPeriod<999)
iPeriod++;
}
else if (iPeriod)
iPeriod--;
sPeriod.Format("%d",iPeriod);
lvi1.iItem = iPos;
lvi1.iSubItem = 2;
lvi1.pszText = sPeriod.GetBuffer();
m_cPlaylist.SetItem(&lvi1);
UpdateData(FALSE);
}
else
{
//AfxMessageBox(IDS_NOT_IMAGE);
}
break;
case DOWN:
case UP:
if(iOp == UP)
iPos2=iPos-1;
else
iPos2=iPos+1;
count = m_cPlaylist.GetItemCount();
if(iPos2<0)
break;
//iPos2 = count-1;
if(iPos2==count)
break;
//iPos2=0;
for (int i = 0; i < m_wndHeader.GetItemCount(); i++)
{
lvi1.iItem = iPos;
lvi1.iSubItem = i;
lvi1.pszText = str1.GetBuffer(255);
lvi1.cchTextMax = 255;
lvi2.iItem = iPos2;
lvi2.iSubItem = i;
lvi2.pszText = str2.GetBuffer(255);
lvi2.cchTextMax = 255;
m_cPlaylist.GetItem(&lvi1);
m_cPlaylist.GetItem(&lvi2);
lvi2.iItem = iPos;
lvi1.iItem = iPos2;
m_cPlaylist.SetItem(&lvi1);
m_cPlaylist.SetItem(&lvi2);
}
data = (listDataStruct *)m_cPlaylist.GetItemData(iPos);
m_cPlaylist.SetItemData(iPos,m_cPlaylist.GetItemData(iPos2));
m_cPlaylist.SetItemData(iPos2,(DWORD_PTR)data);
m_cPlaylist.SetItemState(iPos, 0, LVIS_SELECTED);
m_cPlaylist.SetItemState(iPos2, LVIS_SELECTED, LVIS_SELECTED);
break;
}
}
m_cUpdate.EnableWindow(FALSE);
}
}
thanks, regards...
Giulio
ps. i hope that my english is comprehensible....sorry...ehhehe
|
|
|
|
|
Ing.Raiz82 wrote: question: i want to move two or more element from a list... have you got a idea??
Use the list control's DeleteItem() method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks...
but i don't want delete the element... but i want change the position of two or more element when i click a button UP or DOWN...
bye
Giulio
|
|
|
|
|
Ing.Raiz82 wrote: but i don't want delete the element...
Technically, "move two or more element from a list" implies deleting. Moving an item up and down in the list is an entirely different matter, but easily solved. For example, to move an item up:
void CMyDialog::OnMoveUp()
{
int nIndex = m_list.GetNextItem(-1, LVNI_SELECTED);
if (nIndex >= 0)
{
CString strName = m_list.GetItemText(nIndex, 0);
m_list.DeleteItem(nIndex);
nIndex = m_list.InsertItem(nIndex - 1, strName);
}
else
ASSERT(FALSE);
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi,
I want to know what is the main what is the difference between __cdecl and __stdcall ? Can any one help regarding this.
Regards,
Chinna
|
|
|
|
|
|
A point for you from the direction Mike just pointed you,
<br />
So if you are using a function which is called twenty times, the cleanup code will be placed only once in the function called, if __stdcall is used. But if __cdecl is used, it will be twenty times in the code, i.e., everywhere in main after function is called, and if we have say fifty functions in a file each of which is called twenty times, then the size of the EXE in CDecl will be large. But then what is the advantage of __cdecl... that's something that only C has and not even C++.<br />
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
Hi,
How to change IIS Timeout in MicroSoft C++.
Regards,
Musq
|
|
|
|
|
Is it possible to create #regions in VC++(8.0) IDE ? just like we have in C#? to wrap up a block of code inside.
(-)#region
#end region
|
|
|
(+)region /{}/
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
VuNic wrote: to wrap up a block of code inside.
What do you mean by this?
Normally we would wrap block of code with #ifdef #endif blocks, this enables selected portions of code to be excluded from the build if the appropriate flags are set.
|
|
|
|
|
WalderMort wrote: #ifdef #endif blocks
No it's just for visual purpose. You can "collapse", "expand" a block of code ("region")
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
I see. Not sure about VS2005 but in VS2007 there is a "selection margin" option, which does exactly what you describe. You could still wrap section of code with the #ifdef blocks, and VS will allow you to collapse the whole thing.
#ifdef TRUE<br />
#endif
|
|
|
|
|
WalderMort wrote: #ifdef TRUE
#endif
Yeah something like that, but not exactly.
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
Yes, you can create your own regions for collapsing purposes. Use the
#pragma region
#pragma endregion
directives. See MSDN[^] for more info.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks .
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
in my code i have get the value form the edit control when i got the value it will be in WCHAR
now I need that value int type.
The following thing is compile but run time it will give the error.
WCHAR w_Year[260];
GetDlgItemText(hDlg,IDC_EDIT_YEAR,w_Year,MAX_PATH);
char * Year=" ";
sprintf(Year,"%s",w_Year);
<code>int int_Year=atoi(Year);</code>
is there any other way to get int value;
|
|
|
|
|
atoi() is for an ANSI string, try the UNICODE version instead _wtoi()
|
|
|
|
|
Either use the Unicode function _wtoi() , or GetDlgItemInt() which will do the conversion for you.
|
|
|
|
|
amitmistry_petlad wrote:
WCHAR w_Year[260];
GetDlgItemText(hDlg,IDC_EDIT_YEAR,w_Year,MAX_PATH);
<code>char * Year=" ";
sprintf(Year,"%s",w_Year);</code>
int int_Year=atoi(Year); is there any other way to get int value;
That is part of your problem - even though you are creating a non-const pointer Year , you are assigning it to a constant string, not a real writable buffer, so the code will crash in sprintf(...) when it tries to copy into the memory pointed to by Year . (BTW - %s and %S can be used to format ANSI or Unicode strings in either kind of build; the uppercase %S version formats the opposite type, so in an ANSI build, %S formats a wide string into a narrow buffer, and in a Unicode build it does the opposite.)
The other solutions you have received will get you the integer value of the string obtained from IDC_EDIT_YEAR , but you still should know that what you have tried to do is dangerous.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello,
I'm trying to create a CArchive ar (&f, CArchive::load) object from file f, but when i'm using ar.ReadString()it returns wide characters from chinese charset.The file contains only ascii characters. UNICODE is defined in the application.Do you know what may be the problem? Is there any function usefull?
|
|
|
|
|
Post some code to others understanding.
|
|
|
|
|
Hi all.
I wont to write windows service using "Windows Service" in CLR, but I dont know how it works and whot I can do - whot I cant do.
if you know some booke (English or Russa[Russia]) tell me where can I find it.
thanks for help.
|
|
|
|