|
Sir, I want to make new CSocket object from SOCKET type variable. This SOCKET variable is associated with open socket connection. How can I do it?? would you please help me.......
C.R.Naik
|
|
|
|
|
|
Hi all,
I have a VC module that processing DB on SQL Server and will return a result (number, string,..). Can I rewrite that module so that it can be called from an ASP page on IIS as a function ? How will I do it?
Thanks for your help
|
|
|
|
|
Depends on the complexity of the module. You could write the code again in ASP using ADO to access the database. Or you could wrap your module as an ATL COM component.
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
I would like to load a bitmap file and print it.
I need also to view it in the print preview.
Can anyone send me a simple MFC sample for that?
Thanks,
Dudi
|
|
|
|
|
A lot of the code you need to do this can be found in my article PrintingTricksAndTips[^].
You will need to add the bitmap loading code from resources and convert it to a DIB in your OnBeginPrinting() and destroy it in your OnEndPrintig(). And StretchDIBBits() it in your OnPrint().
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Has anyone noticed that the selecting values with a mouse from the Windows slider control is quite awkward?
In my opinion Microsoft implemented the right click action wrong. For example, if you have a slider control with 5 values and the ticks are marked 1,2,3,4,5, if the slider is currently at tick number 1 and you click on the "4" you would expect the slider thumb directly move to 4, right? Well, what happens is that it moves to "2". This is because it interprets the click as a "page down" command. While this is appropiate for a scrollbar, it certainly is not the right action for a slider. Look at any other non Microsoft slider control(for instance the volumn control in WinAmp) - the thumb moves directly where you have clicked behave in the correct way.
|
|
|
|
|
You COULD subclass and handle WM_(H/V)SCROLL, check for mouseclick and implement the behaviour yourself.
If you do, be sure to post your code here - I am greatly interested
|
|
|
|
|
In fact I already have done this. I just copied this from the round slider project (by Daniel Frey) and removed the drawing code...
class CNiceSliderCtrl : public CSliderCtrl
{
public:
DECLARE_DYNAMIC(CNiceSliderCtrl)
CNiceSliderCtrl() : m_bDragging(false), m_bDragChanged(false) {}
protected:
//{{AFX_MSG(CRoundSliderCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool SetThumb(const CPoint& pt);
void PostMessageToParent(const int nTBCode) const;
bool m_bDragging;
bool m_bDragChanged;
};
#include "stdafx.h"
#include "NiceSlider.h"
IMPLEMENT_DYNAMIC(CNiceSliderCtrl, CSliderCtrl)
BEGIN_MESSAGE_MAP(CNiceSliderCtrl, CSliderCtrl)
//{{AFX_MSG_MAP(CNiceSliderCtrl)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CNiceSliderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bDragging = true;
m_bDragChanged = false;
SetCapture();
SetFocus();
if (SetThumb(point))
{
m_bDragChanged = true;
PostMessageToParent(TB_THUMBTRACK);
}
}
void CNiceSliderCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bDragging)
{
if (SetThumb(point))
{
m_bDragChanged = true;
PostMessageToParent(TB_THUMBTRACK);
}
}
else
{
CSliderCtrl::OnMouseMove(nFlags, point);
}
}
void CNiceSliderCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if(m_bDragging)
{
m_bDragging = false;
::ReleaseCapture();
if (SetThumb(point))
{
PostMessageToParent(TB_THUMBTRACK);
m_bDragChanged = true;
}
if (m_bDragChanged)
{
PostMessageToParent(TB_THUMBPOSITION);
m_bDragChanged = false;
}
}
else
{
CSliderCtrl::OnLButtonUp(nFlags, point);
}
}
bool CNiceSliderCtrl::SetThumb(const CPoint& point)
{
const int nMin = GetRangeMin();
const int nMax = GetRangeMax()+1;
CRect rc;
GetChannelRect(rc);
double dPos;
if (GetStyle() & TBS_VERT)
{
dPos = (double)(point.y - rc.top)/(rc.bottom - rc.top);
}
else
{
dPos = (double)(point.x - rc.left)/(rc.right - rc.left);
}
double dCorrectionFactor = 0.5 *(1-dPos) - 0.5 *dPos;
int nNewPos = nMin + (nMax-nMin)*dPos + dCorrectionFactor;
const bool bChanged = (nNewPos != GetPos());
if(bChanged)
{
SetPos(nNewPos);
}
return bChanged;
}
void CNiceSliderCtrl::PostMessageToParent(const int nTBCode) const
{
CWnd* pWnd = GetParent();
if(pWnd) pWnd->PostMessage(WM_HSCROLL, (WPARAM)((GetPos() << 16) | nTBCode), (LPARAM)GetSafeHwnd());
}
|
|
|
|
|
In the Windows Date/Time Properties dialog under the Time Zone tag, there is a list control with a bunch of time zones. I'm sure you've all seen it before.
Q: Is it possible to programmatically access and enumerate that list?
Thanks,
Jon Sagara
Red Swingline Staplers
|
|
|
|
|
Hi!
The timezones are in the registry. Unfortunally under different keys depending on which Windows version you are running. On NT it's under :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
On Windows 05/98:
On windows 2000 and windows XP I have no idea, but you could search for Time Zones in the registry ...
You can then use RegEnumKeyEx() to loop thru all subkeys.
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Of cause I let the message slip away to soon
On Win 95/98
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
|
I need to install a device driver (self-developed)
in order to allow all system user to use it.
Which is the way ?
Thanks a lot!!!
|
|
|
|
|
Hi
Does anyone know how to print from a VC++ program into a file (not to printer) without the user being required to enter the name of the file at print time
Thanks a lot
xxx
|
|
|
|
|
If you goto the code in ViewPrnt.cpp lines 131 onwards, you can get a copy of the default MFC OnFilePrint() function. Copy this and paste it into your overriden OnFilePrint() function of your view class. You can then mode the code so that it prints directly to a file and deosn't request a filename from the user.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
I have added a menu to my Dialog based app. I wanted to be able to set check marks based on a bool. So what I did was Added functionality to UPDATE_COMMAND_UI. I then call pCmdUI->SetCheck( m_bTest ? 1 : 0 ). I expect that when the bool value changes the check comes and goes. But alas this is NOT the case. Whatever I am not doing also causes all other pCmdUI-> commands to fail. Is this something that cannot be done in a dialog app? I think not. I just don't know what I am forgetting. It looks like the second least talked about item is menues, second to printing. Oh, I know the functions are being called, at least the UPDATE_COMMAND_UI is, based on MessageBox(""); So what ever I am missing has something to do with updating the menu. I have looked at examples and cannot find anything wrong with my function calls. ANY help is apreciated.
Darroll Walsh
Not one person lives in the present. Only the past. I can prove it. Just ask.
|
|
|
|
|
UPDATE_COMMAND_UI is not working in dialogs by default. I can not think of why MS did disable their control updating system in dialogs, but well - there are a lot of weird design flaws in MFC.
What I do im my dialogs (modal in a Doc/view-application, but should also work for dialog-based app) is to handle WM_KIKIDLE:
//called by MFC if 'nothing else to do'.
//Used to send a UPDATE COMMAND_UI-Message to all controls
// thereby simulating the menu-update system via UPDATE_COMMAND_UI messages
// Reference: Paul DiLascia in C++Q&A column
LRESULT CAdvProcDlg::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls(this, false);
return 0;
}
This is working like a charm. Some people complain about using up the processor, but I cant see it.
Hope this helps
|
|
|
|
|
OK I handle the ON_KICKIDLE. But the pCmdUI functions still fail to do anything.
Can I handle a dialog app menu in UPDATE_COMMAND_UI or do I manually need to retrieve the menu with a CMenu class? I hope not.
Thanks for the help.
Darroll
|
|
|
|
|
Maybe you find better help here.[^]
|
|
|
|
|
I have a problem with the position of the toolbars. For a better discription, open wordpad. Dock the toolbars side by side so that they both are in the same row. Now resize the main frame window so that to reduce the size from the right side to the left. Reduce to the smallest possible horizontal width. Notice that the second toolbar that you docked on the right of the first one has moved down. Now resize to increase the size. Notice that the toolbar is NOT moved back to right of the first toolbar. i.e. to its original position before reducing size.
I need to reposition it when the size is increased. Also, I need the docking support on all sides of frame, dynamic size and dock state toggle on double click, so simple rebar cannot be used.
MS Office uses the msoCommandBar which does all the desired, but i cant use it as i dont have its class, control or documentation.
The environment I am using is Visual C++ 6.0 with sp5.
The "Best" is what you can never achieve.
|
|
|
|
|
Hi Everyone:
I try to explan folows,and please help me to judge if it is correct or not.
<hr>
SetWindowOrgEx(hdc,0,50,NULL);
->map the logical point (0,50) to the device point (0,0)
-><a href="http://mail.ntust.edu.tw/~B9007036/Q_1.gif" target="_blank">result</a>
SetViewportOrgEx(hdc,0,50,NULL);
->map the logical point (0,0) to the device point (0,50)
-><a href="http://mail.ntust.edu.tw/~B9007036/Q_2.gif" target="_blank">result</a>
<hr>
But I don't know how to understand and explain when using function
"SetWindowOrgEx" and "SetViewportOrgEx" together in program like follow:
<hr>
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
SetMapMode (hdc, MM_ISOTROPIC) ;
SetWindowExtEx (hdc, 276, 72, NULL) ;
SetViewportExtEx (hdc, cxClient, cyClient, NULL) ;
SetWindowOrgEx (hdc, 138, 36, NULL) ;
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SelectObject (hdc, GetStockObject (NULL_PEN)) ;
SelectObject (hdc, hBrushRed) ;
DisplayTime (hdc, f24Hour, fSuppress) ;
EndPaint (hwnd, &ps) ;
return 0 ;
<hr>
Could someone tell me?Thanks!
The only educated men are self-educated.--J.Bennett
|
|
|
|
|
You should not use SetWindowOrgEx and SetViewportOrgEx together but one or the other! That was my first my first reaction when I look at your code and MSDN confirms it.
MSDN:Generally, you will use one function or the other, but not both. Regardless of your use
of SetWindowOrgEx and SetViewportOrgEx, the device point (0,0) is always the upper-left corner.
ÿVOTD:9 "Be happy, young man, while you are young, and let your heart give you joy in the days of your youth. Follow the ways of your heart and whatever your eyes see, but know that for all these things God will bring you to judgment." - Ecc 11:9
|
|
|
|
|
Hi.Ernest Laurentin
I have already read the MSDN that you say.But this source code named "DigClock" is written by Charles Petzold in Chapter 8 in BOOK "Programming Windows 5/e".
Code
I am very confused and curious.How do we explain when using "SetWindowOrgEx" and "SetViewportOrgEx" together.
Could someone help me?Thanks!
The only educated men are self-educated.--J.Bennett
|
|
|
|
|
Okay, for MM_ISOTROPIC, this is need since this is the only to way to map screen/viewport coordinate by yourself. This is a cool way to obtain Zooming effect for free since SetWorldTransform is not supported under Win 9x. This mode is provide for flexibility if you want to force the mapping of your drawing to a portion of the screen. In Charles Petzold example, he set the Viewport to the screen size (cxClient,cyClient) and the map the Window coordinates to 276x36. In that case all the drawing being done in the screen coordinates (276x36) will be mapped to the viewport. The trick with his code, he already calculates everything to fit his screen 6 characters + 2 colon (6x42 + 2x12 = 276!).
Hope that help!
ÿVOTD:9 "Be happy, young man, while you are young, and let your heart give you joy in the days of your youth. Follow the ways of your heart and whatever your eyes see, but know that for all these things God will bring you to judgment." - Ecc 11:9
|
|
|
|
|