|
Thanks Steve,
(Quick response too! ) I currently have Fengs book and have tried some of examples in the code that I'm doing. I adjusts it too much the other way! Trying to make a WYSIWYG application is not the easiest thing at all.
You by chance don't have any examples that I can sneak a peak at do you?
Larry
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Not without enraging at least half a dozen lawyers!
You need to check his web site for errata (I think there's one in there from me!), and be aware of using reference (or em square?) fonts to derive size information. Generally, his stuff is fine for all but the pickiest of users, although I have had to do some work on things like breaking strings into paragraphs, lines, and words for formatting purposes.
More recently I've worked with FormatRange, having needed RTF editing capabilities for WP like behaviour, and that was an education in itself!
Steve S
|
|
|
|
|
Quote
Not without enraging at least half a dozen lawyers!
Well, we wouldn't want that now would we? I will have to see if I have the URL to his web site. Also, you don't have any test programs when you were learning hanging around do you? Those would do.
Also, I'm using his "Text.exe" example where you can insert the font and point size to get information about that font. I used the equaion to convert the point size into the logical:
Logical = ( point * LOGPIXELSY ) / 72
and found out about the size to enter. Using this information, I'm seeing what happens. The first section adds up correctly. The next character is on smaller, have not done the rest yet...
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Well, I wouldn't. Some of my best clients are lawyers...
I'll dig around my old backup CDs and see what comes out of it. Have to admit I skimmed through some of his examples, because they weren't relevant to what I needed, or in some cases, I already knew what I was doing (which, it has to be admitted, doesn't happen often!).
Good luck
Steve S
|
|
|
|
|
HUMMM.
Using Feng's example "Text.exe" I set the font to 62 (the size on the printer in devics units) and I added up the character width for "RIPTION" in bold/italic and this value was 341. I then used the ABC character widths adding up the values and came up with 357! I checked it several times and it was the same.
I wonder if the amound (difference) gets to be too big, that it adjusts?
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Doesn't surprise me, somehow. This might well account for layout differences in WORD. Although 16/300 of an inch isn't much, over the course of a full line it would increase enough to be noticeable.
Steve S
|
|
|
|
|
Except it is doing it often. I have another that has lots of spaces and it is doing it with the spaces. I'm going to analyis to see where it is doing the adjusting and why. Will post the results.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Steve,
I think I have found it. When I get the sum (from Feng's reference font) and the actual sum of the fonts being calculated, it seems that when the difference gets bigger than +/-1 it adjusts. I printed out the width being calculated in his KTextFormator::TextOut method along with the actual width from GetCharWidth32. When the sums are within +/-1, there is no adjustment, once it goes over that range it adjusts the output position.
Now I need to see if I can implement this and see if it works...
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I've now stopped wondering why anything works, and also why it doesn't.
Having beaten my head against a brick wall by trying to write a SOAP intercepting ISAPI extension according to the spec provided by one of my temporary colleagues, we're now trying a different approach. I only come to CP as therapy - a kind of schadenfreude I suppose, although it's rewarding to answer or join in another coder's problems and get a result.
Steve S
|
|
|
|
|
Well, kiss my grits! It didn't work! It still spreads out. I still think the best way is to let the rich edit output itself, problem is that I also have other graphic objects that are to be drawn and I think the problem is switching from someother mapping mode back to text.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Steve,
Have you been able to find any examples (that the lawyers won't complain about) that I can look at?
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
As part of my techno project I need to be able to emulate my DSP processor in C++. How would I go about outputing a sinewave to the soundcard. I have basic C++ training and can learn fast. Any Help would be appreciated.
Corey
|
|
|
|
|
I want to finish a program that terminates proccesses that are selected in a big list. And my program must run always @ startup. How to terminate proccesses correctly selected in list?
My eyes - fountains of blood
|
|
|
|
|
See if TerminateProcess() helps you.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I know that, ok, my code that doesn't work:
PROCESSENTRY32* info;<br />
HANDLE proc2;<br />
<br />
Process32First(proc2,info);<br />
for(int i=0;i<35;i++){<br />
Process32Next(proc2,info);<br />
MessageBox(info->szExeFile,"OK");<br />
if(strstr("NOTEPAD",info->szExeFile)){MessageBox("MATCH","OK");break;}<br />
}<br />
proc2=OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE,TRUE,1241980);<br />
<br />
m_name.Format("%d",info->th32ProcessID);<br />
SetDlgItemText(IDC_NAME,m_name.GetBuffer(0));<br />
<br />
<br />
if(WaitForSingleObject(proc2,5000)!=WAIT_OBJECT_0){<br />
result=TerminateProcess(proc2,0);<br />
MessageBox("Terminated","OK");<br />
}else{<br />
result=TRUE;<br />
cw=FindWindow(info->szExeFile,NULL);<br />
cw->PostMessage(WM_CLOSE);<br />
MessageBox("TRUE","VIGA");<br />
}<br />
<br />
CloseHandle(proc2);
Well, it's only for testing... Such a mess for testing
|
|
|
|
|
I'm really sorry about the mess above cause i got something...
|
|
|
|
|
PROCESSENTRY32 ProcessEntry;
ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &ProcessEntry) == TRUE)
{
do
{
MessageBox(info->szExeFile, "OK");
if (strstr("NOTEPAD", info->szExeFile)
{
MessageBox("MATCH, "OK");
break;
}
} while (Process32Next(hSnapshot, &ProcessEntry) == TRUE);
}
HANDLE hProcess = OpenProcess(/*PROCESS_ALL_ACCESS*/SYNCHRONIZE|PROCESS_TERMINATE, TRUE, ProcessEntry.th32ProcessID);
if (NULL != hProcess)
{
...
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
HANDLE proc;<br />
PROCESSENTRY32* info;<br />
POSITION p;<br />
int sel=0;<br />
BOOL result;<br />
char *name2;<br />
int length=0;<br />
proc=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
<br />
info=new PROCESSENTRY32;<br />
info->dwSize=sizeof(PROCESSENTRY32);<br />
int id=0;<br />
<br />
Process32First(proc,info);<br />
<br />
p=m_list1.GetFirstSelectedItemPosition();<br />
sel=m_list1.GetNextSelectedItem(p);<br />
<br />
do{<br />
Process32Next(proc,info);<br />
}while(!strstr(info->szExeFile,"NOTEPAD"));<br />
<br />
<br />
proc=OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE,TRUE,info->th32ProcessID);<br />
<br />
m_name.Format("%s",info->szExeFile);<br />
SetDlgItemText(IDC_NAME,m_name.GetBuffer(0));<br />
<br />
<br />
if(WaitForSingleObject(proc,5000)!=WAIT_OBJECT_0){<br />
result=TerminateProcess(proc,0);<br />
MessageBox("Terminated","OK");<br />
}else{<br />
result=TRUE;<br />
cw=FindWindow(info->szExeFile,NULL);<br />
cw->PostMessage(WM_CLOSE);<br />
MessageBox("TRUE","VIGA");<br />
}<br />
<br />
CloseHandle(proc);<br />
delete info;
Well, this should work, but how to use m_mylist.GetItemText(int nItem,intnSubItem,LPTSTR lpszText,innLen) with my code?
|
|
|
|
|
IndrekSnt wrote:
}while(!strstr(info->szExeFile,"NOTEPAD"));
This will loop forever if Notepad is not running!
IndrekSnt wrote:
...how to use m_mylist.GetItemText(int nItem,intnSubItem,LPTSTR lpszText,innLen)...
In order to use CListCtrl::GetItemText() , you must first have added items to the list control. I do not see any calls to CListCtrl::InsertItem() in your code.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I'm not copying all my code but the InsertItem() functions are here:
proc=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
<br />
info=new PROCESSENTRY32;<br />
info->dwSize=sizeof(PROCESSENTRY32);<br />
int id=0;<br />
<br />
Process32First(proc,info);<br />
m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);<br />
<br />
while(Process32Next(proc,info)!=FALSE){<br />
id++;<br />
m_list1.InsertItem(id,(LPCTSTR)info->szExeFile);<br />
}<br />
<br />
CloseHandle(proc);
This here was too only a segment of the code...
|
|
|
|
|
Assuming your list control had another column:
int x = m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);
sprintf(szProcId, "%lu", info->th32ProcessID);
m_list1.SetItemText(x, 1, szProcId);
Otherwise, you'll need to use:
int x = m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);
LPDWORD lpProcId = new DWORD;
*lpProcId = info->th32ProcessID;
m_list1.SetItemData(x, lpProcId);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks, it really helped me out, now i'm executing MSPAINT and NOTEPAD to terminate them...
|
|
|
|
|
How to restore minimized window?
I did so:
and it was not succeded -Why?
<br />
pDlg->ShowWindow(SW_SHOW);<br />
pDlg->SetFocus();<br />
<br />
WINDOWPLACEMENT wndpl;<br />
pDlg->GetWindowPlacement(&wndpl);<br />
<br />
wndpl.length = sizeof(wndpl);<br />
wndpl.flags = WPF_SETMINPOSITION ;<br />
wndpl.showCmd= SW_SHOWMAXIMIZED | SW_SHOW;<br />
<br />
pDlg->SetWindowPlacement(&wndpl);<br />
<br />
<br />
pDlg->UpdateWindow();<br />
thanks.
|
|
|
|
|
vgrigor wrote:
How to restore minimized window?
ShowWindow(SW_RESTORE);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|