|
rp_suman wrote: s it possible to read CSV file from .C file?
Any ideas would be greatly appreciated.
csv is nothing .. it is comma separated file .. you just have to implement logic to extract data from comma separated file
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hello everybody,
In the OnSize-Function, i retrieve the changed Width-Value and changed Height-Value.
then i perform this :
//new position for the Bar
Bar.GetWindowRect(WSize);
ScreenToClient(WSize);
Bar.SetWindowPos(NULL,0,0,(WSize.right - WSize.left),(WSize.bottom - WSize.top)+ChangeY,SWP_NOZORDER | SWP_NOACTIVATE);
//new position for the Tab
Tab->GetWindowRect(WSize);
ScreenToClient(WSize);
Tab->SetWindowPos(NULL,182,3,(WSize.right - WSize.left)+ChangeX,(WSize.bottom - WSize.top)+ChangeY,SWP_NOZORDER | SWP_NOACTIVATE);
if i perform the first SetWindowPos, a new Event is launched directly which provokes some
problems
How can i change the position of these 2 controls and not re-enter in the OnSize?
Thanks
|
|
|
|
|
|
Thanks for your help
The help says me, thats exact what i'm looking for.
But it doesn't work :S
Bar.SetWindowPos(NULL,0,0,(WSize.right - WSize.left),(WSize.bottom - WSize.top)+ChangeY,SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
it steps into it, than before the rest of the OnSize-Code is be executed, he steps at new to this line.
After it, he steps 2 times to the rest of the code.
|
|
|
|
|
baerten wrote: it steps into it, than before the rest of the OnSize-Code is be executed, he steps at new to this line.
After it, he steps 2 times to the rest of the code.
I'm sorry, but I really can't understand your meaning.
You are positioning the windows from your OnSize handler. Here's how it works internally.
When the main window moves or changes a WM_WINDOWPOSCHANGING message is sent, after this a WM_WINDOWPOSCHANGED is sent. During the message, DefWindowProc() detects if the size or position has changed then sends WM_SIZE and/or WM_MOVE .
If you want to move child windows around, it would be better for you to overide OnWindowPosChanging Calculate your new size and position then call SetWindowPos() with the SWP_NOSENDCHANGING flag. This way your controls will be moved/positioned before the main window.
|
|
|
|
|
I have a MDI Child.
In the View i have this "OnSize"-Handler
I always want to resize 2 controls on the view. If the View is getting greater, the controls increase also.
UniView::OnSize(nType, cx, cy);
CRect WSize;
this->GetWindowRect(WSize);
ScreenToClient(WSize);
if(OldSize.top != -9999 && canSize) {
// Calculates the changings
int ChangeX = (WSize.right - WSize.left) - (OldSize.right - OldSize.left);
int ChangeY = (WSize.bottom - WSize.top) - (OldSize.bottom - OldSize.top);
//BAR
Bar.GetWindowRect(WSize);
ScreenToClient(WSize);
// Adds the Difference to the Height -> The bar changes only in height
Bar.SetWindowPos(NULL,0,0,(WSize.right - WSize.left),(WSize.bottom -
WSize.top)+ChangeY,SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); ( A )
//TAB
//Tab->GetWindowRect(WSize);
//ScreenToClient(WSize);
//Tab->SetWindowPos(NULL,182,3,(WSize.right - WSize.left)+ChangeX,(WSize.bottom -
WSize.top)+ChangeY,SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
}
this->GetWindowRect(WSize); ( B )
ScreenToClient(WSize);
OldSize= WSize;
// Saves the current Size of the View, ( used to compare with the new size next time )
if i place a breakpoint to A and B it stops as follows
A,A,B,B ... if the line (A) is executed, it steps at new on (A), before it reaches (B)
Or does it exist a easier way to fit the controls ?
Thanks
|
|
|
|
|
Hi
I have some (probably) basic questions about CToolbar class, just point me somewhere (article, code or just general idea)
How to change button's position? - I would like to move them closer, without a single pixel of free space between. (or just 2 pixels right and bottom for 'press' effect)
How to disable this square box around button's bitmap when I hover/press the button?
And finally what message/base class member function should I override to make my bitmaps transparent? I have already handled WM_ERASEBKGND message but now my buttons have plain background instead of a bitmap. I've seen some articles about it but the solutions are not so simple (many lines of code, message handlers ect.) Is there a simple way how to draw CBitmap 24bit bitmap on a CToolBar control? Assuming some transparency RGB value in my input bitmap?? (Let's assume Windows 2000+ environment)
Thanks in advance!
|
|
|
|
|
First - Toolbar Controls Overview[^]
PatrykDabrowski wrote: How to change button's position? - I would like to move them closer, without a single pixel of free space between. (or just 2 pixels right and bottom for 'press' effect)
A combination of TB_SETMETRICS message to set button spacing and using separators between
buttons will help for custiomizing spacing.
PatrykDabrowski wrote: How to disable this square box around button's bitmap when I hover/press the button?
Use image lists to have control over button images.
PatrykDabrowski wrote: And finally what message/base class member function should I override to make my bitmaps transparent?
This has nothing to do with WM_ERASEBKGND (actually toolbars have the TBSTYLE_TRANSPARENT style
so you don't have to do that). For the button images you need to use a masked image list with
the mask created using a certain color in the bitmap that represents transparent.
For example, this code takes a 24bit source bitmap resource and creates a masked image list
from it, using bright green as the transparent color...
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
m_ToolBarImageList.Create(32, 32, ILC_COLOR24|ILC_MASK, 2, 1);
m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
When the toolbar is created set its image list to the image list created above:
static TBBUTTON ToolBarButtonDescs[] =
{
{0, ID_BUTTON1, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
{1, ID_BUTTON2, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0}
};
m_ToolBar.CreateEx(this, TBSTYLE_FLAT);
m_ToolBar.SetSizes(CSize(39,38), CSize(32,32));
m_ToolBar.GetToolBarCtrl().SetImageList(&m_ToolBarImageList);
m_ToolBar.GetToolBarCtrl().AddButtons(2, ToolBarButtonDescs);
|
|
|
|
|
Thanks for help but it seems not working for me... But first, my second question. I was asking how to disable this square "3d-like" frame around my buttons. Image lists do not solve this problem because they are 32x32 pixel and this box is bigger, about 38x38 pixels.
I have partialy solved this problem by this code:
void CToolBarEx::OnTbnHotItemChange(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = (1-m_bHoverMouse); //0=no change;1=no box around buttons
}
and now, when I move the mouse over buttons, this box is not drawn but when I press the button it is still there...How to disable it completly??
To my last question, I have almost copy-pasted Your code to my app but the buttons are still opaque. I have a transparent color RGB(255,0,255) in my bitmap containing 6 buttons (192x32 24bit bitmap). Now the transparent color is not directly drawn but replaced by the plain gray (background) color. That would be fine, but I have a background bitmap?!?
Maybe the way I'm drawing my background bitmap is wrong??? The drawing code is:
BOOL CToolBarEx::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect); //toolbar rect
CBrush *m_brOld = NULL; //Old brush
m_brOld = pDC->SelectObject(&m_bgBrush); //load my background brush
pDC->FillRect(&rect,&m_bgBrush); //fill the whole toolbar
pDC->SelectObject(m_brOld); //restore original brush
return TRUE;
}
Maybe I should save somehow this brush into the toolbar's DC for proper background drawing when the control draw its buttons?? How to "tell" the control to use bitmap/brush to draw its background??
Thanks again I'm waiting for Your response...
|
|
|
|
|
PatrykDabrowski wrote: I was asking how to disable this square "3d-like" frame around my buttons. Image lists do not solve this problem
because they are 32x32 pixel and this box is bigger, about 38x38 pixels.
The closest I think you'll get is using the TBSTYLE_FLAT style. But you'll still see the hot-
track, 3d button outline indication.
The buttons are 7 pixels wider and 6 pixels higher than the bitmaps. I tested to see if this
could be changed but the system defaulted them.
OnEraseBkgnd is fine but the buttons are not drawn transparently. The images on the buttons are.
This is the behavior of the toolbar control. The 3d box around buttons indicates to the user
that it's a button.
You could use the TBSTYLE_CUSTOMERASE style and respond to NM_CUSTOMDRAW messages. In the passed
NMTBCUSTOMDRAW struct there's a NMCUSTOMDRAW struct member that you can look at to see if a button
is about to be drawn hot and if so, change the state to normal so it gets drawn normally.
You could also draw the buttons yourself.
It sounds like you may just need to transparently draw images on a background and respond to
clicks within the images. Maybe that's a viable alternative route as well(?)
Mark
|
|
|
|
|
hi all
Any sample projects for devoloping XPCOM .Plz help me
#sanroop#
|
|
|
|
|
Here[^]is one of the links that I used.
You can just type in XPCOM in google and find a lot more similar pages.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Sanroop wrote: hi all
Any sample projects for devoloping XPCOM .Plz help me
google is your friend dude., or llook for forums that support open source development
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
hi all
i am working on a routine where i need to know the status of network .i e., the net is connected ot not.be it in dial-up network ,DSL cable or anything i need to know about the availability of the net
please help me
thanks in advance
sudhir
|
|
|
|
|
use "IsNetworkAlive" method it will shows Which network is connected to ur system ie whether its LAN or any thing
#sanroop#
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hi all,
How can I detect that the network cable is unplugged/plugged? . And I need to find out the network status anytime be it in any like dial-up network and
cable network .
please help me in this regard
pradeep
pradeep
|
|
|
|
|
|
See here. There's also the ISensNetwork interface.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In addition to the method suggested by David, you can also use InternetGetConnectedState to get the connection state.
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
|
I've created a menu called Tools where in I have created a menu item called Preferences. If we click the Prefernces menu item Preferences Dialog Box will open. In that Dialog Box I have an edit box. The message entered in this edit box is displayed in the second panel of the status bar (i.e) panel no.1.
My Requirement is:
The second panel should be of a default size and it should grow according to the length of the message entered in the edit box.
How can I achieve this in MFC? Can any one help?
I have tried this also. But it didn't work.
CStatusBar::SetPaneInfo( int nIndex, UINT nID, UINT nStyle, int cxWidth );
The function that displays the message is:
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
char str1[150];
//int len = message.GetLength();
sprintf(str1, "%s",message.GetString());
pCmdUI->Enable(TRUE);
pCmdUI->SetText((const char *)str1);
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
}
When I remove the comment from the following code, it shows me an exception stating that "Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014."
The commented out line of code is:
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
Any one Please help.
|
|
|
|
|
I have tried with an and this code works.
May be something else is wrong...
CString message;
message = "A LOOOOOOOOOOOOOOOOOOOOONG MESSAGE000000";
int len = message.GetLength();
m_wndStatusBar.SetPaneText(1,(LPCTSTR)message,FALSE);
m_wndStatusBar.SetPaneInfo(1, 1, SBPS_STRETCH, len);
|
|
|
|
|