|
Consider that you have a list control. This control has items placed into it. Each item has an image portion and a label portion, and these two together form the item's boundaries.
Now, you can get the rectangle of either the image, the label, or the entire boundary by using CListCtrl::GetItemRect and specifying one of the flags. If the label already has text, then you must query the list control for the font it uses (the system font, by default), then calculate the height of the text based on the font.
I am not sure if there is a direct method, but as CListCtrl is derived from CWnd , it should support GetFont method call. The best way, of course, would be to query a CWnd -pointer into the individual item, then query for the font. But how to get a pointer to the subitem's CWnd is something I have no clue of, as list control items are handled by the LVITEM structure. I'd first try using the GetFont call of the list control itself.
By getting the label rectangle, you can measure the maximum height of the text. This allows you to select a font size and typeface that fits smoothly into the area. SetFont , I think, allows you to select the font used. Again, experiment to be sure.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hiya I am trying to learn about serial comms. I have been trying to learn from an article on Code Project. But there seems to be alot to it.
What I am trying to do is send a file from one pc to other.
Has anyone done this before and could u please give me an example of doing this.
Thank you for any help.
|
|
|
|
|
that's not the correct place to ask this, except if you want to do it by yourself in Visual C...?!
TOXCCT >>> GEII power
|
|
|
|
|
Hey all.
I have an application, and I used the article by ashman to allow me to minimize to the system tray. Almost everything is working excellent, except I've noticed one flaw.
When I minimize the program to the taskbar, there are two ways to restore it. One way would be to double click, the other way would be to right click on the icon, and click restore. Right clicking and selecting restore works perfect, however, the double click does not.
I have checked the code (and put an AfxMessageBox() in there to make sure it was getting called correctly), and both the right click event as well as the "click on restore button" event are calling the same method to restore the window. When I double click on the icon, the window title appears on the taskbar (as it should) but it does not restore and show it. It just puts it on the taskbar, and the only way to view the window is to actually click on another program that's running in the taskbar, and then click on my program on the taskbar afterwards ... then, it appears as it should.
I can not figure out why since it is calling the same exact method it is behaving differently. What I have in the restore code is this:
ShowWindow(SW_RESTORE);
m_bHidden = FALSE; // <- this is just a variable that tells the program if its hidden or not
I've tried a plethora of ideas to make it work by putting different ShowWindow(SW_SHOWNORMAL), SW_SHOWDEFAULT, etc.... The only way that it seems to work (but only some of the time) is if I do ShowWindow(SW_SHOWMAXIMIZED); ... Then half of the time it pops up full screen and works great. The only problem here is that I have developed the app for a specific size and I do not allow the user to maximize, neither have I added any code to allow for this, so when I call ShowWindow(SW_SHOWMAXIMIZED) it looks very ugly.
Oh, and here's some other information. After I do this the first time (I restore the window, click on another program in the taskbar, then click on my program and regain view/focus), it works fine every time after that with the double click function. It's only the first time that the user tries to restore that I am running into the problems. Also, if I do:
ShowWindow(SW_SHOWMAXIMIZED);
Sleep(1000);
ShowWindow(SW_SHOWNORMAL);
Every time it pops up just fine (but obvisously there is a 1 second delay in there which stinks)
I am wondering how I can "un hide" a window, and set focus on it and ensure this happens every time. Any help would be appreciated.
|
|
|
|
|
|
Given the files below I am getting multiple errors . I think I need a point.cpp and a main driver, having a hard time tying it all together
is there a way to upload files instead of pasting all the code in 6+ files? soemone let me know please
Thanks
Thanks
|
|
|
|
|
Given the files below I am getting multiple errors . I think I need a point.cpp and a main driver, having a hard time tying it all together
is there a way to upload files instead of pasting all the code in 6+ files? soemone let me know please
Thanks
|
|
|
|
|
Yes
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
|
carefully
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
How can I know from where an executable file is loaded?
After compilation, the executable fill will be saved in somewhere,
how can I know it's location when the file is executed.
For example, if the file is C:\myfile\test.exe, I want to print out C:\myfile when test.exe is run, if the file is moved to C:\another-folder\test.exe, I want to print out c:\another-folder when it is executed.
Thanks a lot!
George
|
|
|
|
|
GetModuleFileName()
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
|
|
How to build MFC libs, so I can debug inside MFC code.
Agha Khan
|
|
|
|
|
I wanted to make a look something like this:
_________________
|************|**|
|************|**|
_________________ <- I can't get this splitter bar
|***************| (m_splitterWnd) to his right position
_________________ I've set the sizes right, but it doesn't work
The strange thing is that if I change the layout to:
____________________
|*****************|
___________________
|**************|**|
|**************|**|
____________________
it works... why?
Try to explain this code...
<br />
RECT clientRect;<br />
GetClientRect(&clientRect);<br />
int iHeight = clientRect.bottom - clientRect.top,<br />
iWidth = clientRect.right - clientRect.left;<br />
<br />
<br />
m_wndSplitter.CreateStatic(this, 2, 1, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST);<br />
m_wndSplitter1.CreateStatic(&m_wndSplitter, 1, 2, WS_CHILD | WS_VISIBLE,<br />
m_wndSplitter.IdFromRowCol(0,0));<br />
m_wndSplitter1.CreateView(0, 0, RUNTIME_CLASS(CEditView),<br />
CSize((int)(iWidth * 0.8), (int)(iHeight * 0.7)), pContext);<br />
m_wndSplitter1.CreateView(0, 1, RUNTIME_CLASS(CEditView),<br />
CSize((int)(iWidth * 0.2), (int)(iHeight * 0.7)), pContext);<br />
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CEditView),<br />
CSize(iWidth, (int)(iHeight*0.3)), pContext);<br />
Thanx... any help will be appreciated
..:: a l i e n ::..
|
|
|
|
|
Hello people,
I urgently need to look at a piece of code for checking whether the brackets AND braces of an algebraic expression are nested. I've been trying to write it for a couple of days, but I still cannot get it to work, too many nested loops for my level. If you have the time, can you look and tell me whats wrong with my code? If not, I think if I look at a correctly working one, it would help. Thanks in advance,
timepanicked
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
using namespace std;
int red_checker(string a, int size, int l, int open_curr, int closed_curr, int diff_open, int diff_closed)
{
int e=l, f,x, d, b, r, n,c;
while (l>0)
{
cout<<"while # 0"<<endl;
while="" (="" a[l]="" !="open_curr)" looks="" for="" open="" sign="" under="" current="" inspection
=""
="" {
="" cout<<"while#1"<<endl;="" l--;
="" }
="" if="" (l="=0)" reached="" beginning="" of="" array
="" {="" and="" opening="" not="" found=""
="" (n="0;" n<size;="" n++)
="" cout<<"for#1"<<endl;
="" closed_curr)="" but="" closing="" return="" 2;="" 2--=""> not nested
}
return (red_checker(a,size,e,diff_open,diff_closed,open_curr,closed_curr));
//call funct to check other bracket type
}
for (f=l+1; f<size-2, a[f]!="closed_curr;" f++)="" check="" array="" after="" open="" sign="" to="" find=""
="" {
="" cout<<"for="" #2"<<endl;
="" }="" if="" a="" closed="" one="" matches="" it
="" (a[f]!="closed_curr)" not="" found
="" return="" 2;
="" else="" (a[f]="=" closed_curr)
="" {
=""
="" for(b="l+1;" b<f;="" b++)="" now="" see="" there="" is="" the="" other="" bracket="" type="" in-between...
="" #3"<<endl;
="" (a[b]="=diff_closed)
" 2;
="" #4\n";="" for="" (c="b+1;" c<f;="" c++)="" ...and="" it="" nested
="" (a[c]="=" diff_closed)
="" a[c]="a[b]=0;
" break;
="" }
="" }
="" a[l]="0;" a[f]="0;
" cout<<"we="" set="" and="" "<<a[f]<<a[l]<<endl;
="" }
="" }
}
int="" main="" ()="" {
string="" a;
int="" v="0," z="0," l,="" j,="" size;
ifstream="" greenstream;
="" greenstream.open("greenfile.cpp");
="" greenstream="">>a;
greenstream.close();
size = a.length();
l=size-1;
v = red_checker (a, size, l, '(', ')', '{', '}' );
z = red_checker (a, size, l, '{', '}', '(', ')' );
if (v==2 || z==2)
cout<<"Input in greenfile is not nested"<
|
|
|
|
|
For starters:
Anonymous wrote:
int e=l, f,x, d, b, r, n,c;
You need to do this in C. In C++, it's much better to declare your variables as you use them, and certainly to give them an initial value. My first suspicion was an uninitialised variable from this list, but the function is too long for me to bother trawling through for variables that have random values from the top of the function.
Anonymous wrote:
string a;
int v=0, z=0, l, j, size;
ifstream greenstream;
greenstream.open("greenfile.cpp");
greenstream>>a;
This will read the file until the first whitespace character into the string. It won't read in the entire file.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am connecting to a remote SQL Server in my software. Its all working fine.. but on some PCs it gives exception and connection is not made. What are strict requirements for connecting to a remote SQL Server. My SQL Server uses SQL Server based authentication.. I heard that Win XP machine cant conenct to SQL Server if there is no password of Win XP machine.. plz tell me strict requiremnts
Thanks
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
I have been given a rather unfortunate assignment at work:
I have to look into what it would take to put a COM wrapper around a small multi-threaded C++ API that I wrote. It seems a client is interested in the API if it can support VB. I have the option of telling my boss it's impossible and that he should tell them to toss off. My assumptions are that they are using VB6.
I've done ATL before but never in wrapping a multithreaded API that had to work in VB. Any suggestions? Besides the obvious that all the com objects need to be dual interface (IDispatch), is there any thing funky I need to do to handle the fact that the lib uses multiple threads internally?
Basically the VB client would do nothing more than
- create the app instance (the app would house my library)
- init the app (App.Init or something like that)
- run it (App.Run)
- respond to events
The VB client has no need to work in multiple threads, or be aware of their presence.
Any suggestions would be *most* appreciated!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Jim Crafton wrote:
The VB client has no need to work in multiple threads, or be aware of their presence.
You will need to be careful how your events are passed to the VB client. It may expect or require that callbacks to it are on the GUI thread.
It's probably not the right way to do it when using COM (all that apartment stuff comes to mind), but I've used the 'hidden window and user-defined messages' trick to handle this. In the GUI thread, create a hidden window. Your event handler, which is called on an unknown thread, uses ::PostMessage and the window's handle to drop a message into the hidden window. The hidden window, running on the GUI thread, processes the user-defined message and handles the event. If the event has information, you can use the WPARAM and LPARAM arguments for small things, or pass pointers to objects allocated from the heap. If you do the latter, you need to ensure that the hidden window has a WM_DESTROY handler that will run the message pump dry via PeekMessage and delete the arguments.
The event handler and the GUI thread are decoupled in this case, which can be useful. The event handler doesn't block (except briefly during the PostMessage call). Events are maintained in order by the hidden window message queue.
Software Zen: delete this;
|
|
|
|
|
I've tried to make an Idle time processing in an MDI project, but even if there are no messeges for the window the lCount doesn't go higher then 1... => I've tried to see what's going on in the thCore, but I couldn't figure'it out.
Any tip would be appreciated.
10x
..:: a l i e n ::..
|
|
|
|
|
CWinApp::OnIdle will return FALSE when it is done. If you want to insert idle processing after that, you have to get your override to return TRUE. If it returns TRUE, OnIdle() will be called with an increased lCount.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Can anyone assist with a template or code for stacks and ques?? I have been thrown into a class with little foundation, so any help is appreciated.
Hi_Pdale Here
|
|
|
|
|
these are the standard C++ container :
#include <list>
#include <vector>
#include <queue>
all these are from the std:: namespace.
you can also read The C++ language from Bjarne Stroustrup for more infos.
TOXCCT >>> GEII power
|
|
|
|
|