|
Sir, I want to flush out the socket buffer. But I can't get the way to do that. Help me....
C.R.Naik
|
|
|
|
|
you can't AFAIK.
Btw, the proper sequence for closing a TCP connection is:
Finish sending data.
Call shutdown() with the how parameter set to 1.
Loop on recv() until it returns 0.
Call closesocket().
http://tangentsoft.net/wskfaq/newbie.html#normalclose
M
|
|
|
|
|
How can I move a CTreeCtrl item to a other position?
Item 1
SubItem 11
SubItem 12
SubItem 13
Item 2
SubItem 21
SubItem 22
SubItem 23
So I want to move Item 2 with all subitems (up or down):
Item 2
SubItem 21
SubItem 22
SubItem 23
Item 1
SubItem 11
SubItem 12
SubItem 13
How can I make this? (I want to move the current selected item with all subitems up or down)
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
There's no built in method that does this. The only way I'm aware of is to manually walk the tree, create new items with the same attributes as the old ones and finally delete the old ones. It would probably be a good idea to disable redrawing in the control while doing this ( m_wndTreeCtrl.SetRedraw( FALSE ); at the beginning and m_wndTreeCtrl.SetRedraw( TRUE ); when everything is finished.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I have a MFC MDI program, where I want to have in their own
MDIchildframe windows both CScrollView based view and CListView
based view. (Data neatly in CListView window, graphics in CScrollView window)
How can I accomplish that?
TIA
-Marko
|
|
|
|
|
Do I need to use CMultiDocTemplate in CApp::InitInstance? Is that what I should read about or do I risk learning something for nothing?
|
|
|
|
|
Yes, you need to use an addtional CMultiDocTemplate object:
pDocTemplate = new CMultiDocTemplate(
IDR_PGPCONTYPE,
RUNTIME_CLASS(CSGAControlDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CYourScrollView));
AddDocTemplate(pDocTemplate);
pDocTemplate = new CMultiDocTemplate(
IDR_PGPCONTYPE,
RUNTIME_CLASS(CSGAControlDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CYourListView));
AddDocTemplate(pDocTemplate);
By default this will register 2 view types wit hteh same document. When you create the document you will be asked which type of view you want. To add the other view type, you will have to write a function thats adds the new view to the existing document. I did this a while back, but the code has since gone obselete in my app and has been deleted, so I don;t have any example code ready to hand.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
I can easily see all the printers connnected / installed by using EnumPrinters, but when I view them from Control Panel - Printers, they all say Status - "Ready", and I know for a fact that one of them is turned off!! Anyone know how I can tell there true status of a printer please?
Thanks
I feel like I'm diagonally parked in a parallel universe
Jeremy Davis
http://www.astad.org http://www.jvf.co.uk
|
|
|
|
|
Hi,
I am using static controls to display bitmaps in my dialog-based app. I am not using MFC. The bitmaps in the main dialog window display correctly, but the bitmaps in child dialogs (such as my 'About' dialog) do not appear at all.
I am doing exactly the same thing for the child dialogs as for the main dialog (using static control, selecting bitmap and the bitmap resource ID)
so what's going on?
Thanks, any suggestions welcome
|
|
|
|
|
Is the About dialog's static set to type BITMAP?
|
|
|
|
|
The settings are:
ID: IDC_STATIC
Type: Bitmap
Image: IDB_BITMAP2
There is a valid bitmap resource called IDB_BITMAP2. The thing I can't understand is why it works in the main dialog, but no bitmaps appear in the About dialog??
|
|
|
|
|
Hi,
I'm working on an application with many forms, i designed a layout for all the forms, but i wanted to build a class that had OnDraw(CDC* pDC) so i didn't have to override it from all my CFormView derived classes.
I created a CLayout Class with OnDraw(CDC* pDC) function and now i would like to call it from other classes so i could draw and paint the forms.
But, how can i get the pDC of this form?
And i also need the hWnd pointer in my CLayout::OnDraw Function
In my derived call i wrote:
HWND* hWnd=NULL;
hWnd=(HWND*)this->operator HWND();
CDC pDC=::GetDC(*hWnd);
CLayout ly(hWnd);
ly.OnDraw(&pDC);
...but GetDC function returns a HDC no CDC...
This is my OnDraw Function...
void CLayout::OnDraw(CDC* pDC)
{
//cria os objectos
CBrush brush(RGB_FUNDO);
CBrush* pTempBrush = NULL;
CBrush OrigBrush;
CString sFormName="New Machines";
CFont hFont;
CRect rc;
try
{
//cria a fonte para as letras de identificação do form
VERIFY(hFont.CreateFont(40, 15, 0, 0, FW_NORMAL,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial Bold"));
//define a area total do ecran
GetClientRect(*hWnd,&rc);
ScreenToClient(*hWnd,&rc);
//seleciona o brush (cor) a usar
pTempBrush = (CBrush*)pDC->SelectObject(brush);
//guarda o brush original
OrigBrush.FromHandle((HBRUSH)pTempBrush);
//desenha o rectangulo a pintar com aquele brush
pDC->Rectangle(0, 0, rc.Width() , rc.Height());
//defino a cor do texto
pDC->SetTextColor(RGB_WHITE);
//elimino o bkgrn do texto
pDC->SetBkMode(TRANSPARENT);
//associa-lhe a fonte criada
pDC->SelectObject(hFont);
pDC->DrawText(sFormName, -1, CRect(15, 0, rc.Width(),80), DT_LEFT|DT_SINGLELINE|DT_VCENTER);
}
catch(CResourceException* e)
{
e->ReportError();
e->Delete();
}
pDC->SelectObject(&OrigBrush);
}
What am i doing wrong
Thank you for your time
rui
|
|
|
|
|
You could try
<br />
CClientDC dc( this );<br />
CLayout ly( *this );<br />
ly.OnDraw( &dc );<br />
but if this code gets called in OnPaint then you should use CPaintDC instead.
You also might get away with supplying the hWnd of the form because CDC has a member function GetWindow( ) which returns the window associated with the device context (if there is a window BTW - returns NULL during printing for instance).
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Thank you dabs,
I changed my code, now in my CFormView derived class OnInitialUpdate() i did like:
ClientDC dc( this );
CWnd* cWnd=dc.GetWindow();
CLayout ly(cWnd );
ly.OnDraw( &dc );
then, i CLayout
CRect rc;
cWnd->GetClientRect(&rc);
GetClientRect((HWND)cWnd, &rc);
cWnd->ScreenToClient(&rc);
but rc is like : tagRECT: {top=32730 bottom=32730 left=32768 right=32768}
well, i forced other values, and it didn't draw the same, but in debug mode, i follow the pointer and it seems ok.
What can i be doing wrong?
Thanks once more for your time
|
|
|
|
|
Looks like you are using a CWnd* as a HWND. I recommend using Hungarian notation to be able to spot such problems - your variable would be called pWnd in that case. Secondly, you don't need that ScreenToClient call since GetClientRect uses client coordinates already.
So change this code:
<br />
CRect rc; <br />
cWnd->GetClientRect(&rc);<br />
GetClientRect((HWND)cWnd, &rc);<br />
cWnd->ScreenToClient(&rc);<br />
to this:
<br />
CRect rc; <br />
cWnd->GetClientRect(&rc);<br />
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Thank you dabs for the recommendation,
I changed my code, it runs, in debug mode it passes without any problem by all code lines.
Maybe the way i'm passing the pWnd pointer is incorrect, i'm doing like:
CLayout::CLayout(CWnd* pWnd1)
{
pWnd=pWnd1;
}
pWnd is a member variable of CLayout
My class is :
class CLayout
{
public:
CLayout(CWnd* pWnd1=NULL);
~CLayout(void);
CWnd* pWnd;
public:
virtual void OnDraw(CDC* pDC);
};
Should it be derived from CFormView also?
I don't understand, it just don't draw, well, now rc is 0 for the four items...so it couldn't draw
I'm suspicious about the pWnd that i pass from one class to another.
What do you think?
Thank you for your patience
|
|
|
|
|
The CWnd declaration and initialization is correct. And no, this class should not derive from CFormView unless you want to create another form
What happens in your Form's OnDraw and/or OnPaint functions?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Well, i'm just Using OnDraw()
The function is :
void CLayout::OnDraw(CDC* pDC)
{
//cria os objectos
CBrush brush(RGB_FUNDO);
CBrush* pTempBrush = NULL;
CBrush OrigBrush;
CString sFormName="New Machines";
CFont hFont;
CRect rc;
try
{
//cria a fonte para as letras de identificação do form
VERIFY(hFont.CreateFont(40, 15, 0, 0, FW_NORMAL,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial Bold"));
//define a area total do ecran
pWnd->GetClientRect(&rc);
//seleciona o brush (cor) a usar
pTempBrush = (CBrush*)pDC->SelectObject(brush);
//guarda o brush original
OrigBrush.FromHandle((HBRUSH)pTempBrush);
//desenha o rectangulo a pintar com aquele brush
pDC->Rectangle(0, 0, rc.Width() , rc.Height());
//defino a cor do texto
pDC->SetTextColor(RGB_WHITE);
//elimino o bkgrn do texto
pDC->SetBkMode(TRANSPARENT);
//associa-lhe a fonte criada
pDC->SelectObject(hFont);
pDC->DrawText(sFormName, -1, CRect(15, 0, rc.Width(),80), DT_LEFT|DT_SINGLELINE|DT_VCENTER);
}
catch(CResourceException* e)
{
e->ReportError();
e->Delete();
}
pDC->SelectObject(&OrigBrush);
}
I used this function in a OnDraw override from CFormView in my other class and i never thought it would be so dificult to make a class just for the propose...
I would appreciate very much if you could still hepl me with this, thanks a lot
|
|
|
|
|
Aside from the fact that you are casting a CBrush* to HBRUSH (which won't work) and that you forget to deselect your font out of the device context then there's nothing inherently wrong with this code. But why don't you simply use the resource editor in Visual C++ to arrange the form in a way you want? There are controls available that allow you to change the color of static text easily and if you want another background color in your form you can handle WM_ERASEBKGRND to change it. You actually don't need to do anything at all in OnDraw if you don't want to. Or are there other requirements that I'm not aware of?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I'm working with vc.nte, i don't know if it makes a diference...
That cast is part of a piece of code i got and it worked, i hope that is not the reason this doesn't work.
And, honestly, i don't know how to deselect my font out of the device context.
The main reason i'm trying to do this is because the forms layout isn't completly defined, so if later i had to make changes in all, it would be easier, and if i could spare from creating more objects in my forms it would be better, but maybe that is what i'm going to do...
Thank you a lot for your time and dedication
rui
|
|
|
|
|
Well you are correct - it shouldn't have to be that hard to display the form And it does not have to be - as I said I think you would be better off by using the dialog editor in VC++.
The brush handle vs pointer can easily be resolved though if you want to but since this code isn't working then there's not much point in it really...
And to deselect the font you should use a similar technique as with the brush - i.e. save the old font and select it back when you are done with the one you are using.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi all,
I'm trying to implement a custom windows control, (not ActiveX control) and basically cannot succeed when using MFC.
I'm very familiar with straight Win32 programming in C/C++ and built some custom controls from scratch using WTL, but I cannot do it in MFC. It seems the problem lies in the way MFC handles a permanent map. I couldn't do this from either a regular DLL using MFC as a shared-library, nor an MFC-extension DLL.
Please, note that the DLL doesn't export any class. Only a single function InitWindowsControls() that registers the appropriate window class for the controls implemented in the DLL.
Any pointers?
Cheers.
--
Maxime Labelle
maxime.labelle@freesurf.fr
|
|
|
|
|
Hi,
I am using MSComm32 ActiveX in my application. I have a little problem with the following:
If I open the Com port using my app. and then try using the HyperTerminal to open the same com port, the HyperTerminal informs us that the port is already being used by some other program. If I close my app. the HyperTerminal can then open the port.
When I first open the com port with HyperTerminal and then try opening the com port with my app. the ActiveX also informs us that the port is already open. But if I close the HyperTerminal and try with my app. again, the ActiveX indicates that the port is closed and then when I try to open it I get an error.
The only way I can then get access is by resetting the modem attached to the com port and opening the com port.
Does anyone know how to fix this? Have you had the same problem?
Thanks
Regards
Rui
|
|
|
|
|
|
Only one application may have a given port open at a time. For example, if HyperTerminal has COM1 open, your application can not open COM1 as well.
If you want to use HyperTerminal to test your application, connect a null modem cable between COM1 and COM2. Run HyperTerminal using COM2, and your application using COM1.
Software Zen: delete this;
|
|
|
|
|