|
If VC++ 6.0, use the ClassWizard and set up a member function for WM_LBUTTONDOWN.
If VC++ 7.1, don't use the Classwizard ('cause it 'taint there) and set a handler for WM_LBUTTONDOWN
If your using VC .NET, I haven't the clue. It's too safe for me anyway.;P
(In .NET it's probably in the System.Computer.Actions.Mouse.MouseActions.ButtonActions.PressedActions.LeftButton.Down namespace or something hideously long like that)
-- modified at 20:25 Wednesday 12th April, 2006
|
|
|
|
|
I need to get text from my Edit Controls, which are CString types, and convert them to char arrays which I later store in the header of my binary file. I can do this easily if I specify my character set to be Non Unicode and use strcpy . The problem when I do this is that all my dialogs and buttons revert back to the Windows 2000 style, rather than the WinXP style. It is not really a bid deal, but I would like the application to look as up to date as possible.
Can anyone tell me how to convert CStrings into char arrays, using Unicode, or how to get WinXP dialogs with a Non Unicode character set? What I am getting at may be a little vague so let me know if you need me to explain it in more detail.
Any help is appreciated. Thank you!
|
|
|
|
|
If all you need to do is copy the data from the CString and write it to a file, you do not need to copy the contents of the string to a non-const buffer. CString objects have a LPCTSTR operator, which means that you can use it in place of a const TCHAR * .
Since the CString class is TCHAR -based, it supports Unicode. You can convert the string to ANSI for writing it to a file using the ATL Conversion Macros (T2CA ) if the data is not too large, or calling WideCharToMultiByte(...) yourself with your own buffer(s).
Also, if you get into the habit of using the TCHAR -based string functions, you life may get easier (i.e. using _tcscpy(...) instead of strcpy(...) ).
Look up how to create (and optionally embed) a common control manifest file; that should help you with getting the XP-style controls back into the application when running it in ANSI mode.
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
hello Everyone,
I am a beginner in Visual Studio C++.
In all I have read till know I can't find an example of how to plot,
let say i have x=[1 3 7 ] and y=[7 9 10]
i want to build an application where i press the button PLOT and it plots y versus x in circle (or line) in and a given color
I would really appreciate your help.
thanks again
|
|
|
|
|
You have to research device contexts. All "plotting", or any graphical output for that matter, in Windows is accoplished through a device context.
CDC *pDC;<br />
<br />
pDC->MoveTo(x1, y1);
pDC->LineTo(x2,y2)
pDC->Ellipse();
pDC->Rectangle();
There are many more features to device contexts which should allow you to do what you want. Any good Visual C++ book should talk about DC and I know this web site has A LOT of useful examples.
Hope that helps.
Paul
|
|
|
|
|
ilda lapi wrote: I am a beginner in Visual Studio C++.
In all I have read till know I can't find an example of how to plot,
In addition to the post on DC, you can also change that context into either an OpenGL or Direct3D display, thus allowing you a full range of very low-level drawing functions.
and there are additional methods such as GDI+ depending on your needs. http://www.codeproject.com/miscctrl/pgllib.asp[^]
there are actually quite a few ways to do plotting through various frameworks to libraries.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I have to develop a device driver for windows NT that will add a virtual audio device to the system. i need to hook up and capture the audio stream coming from microphone and send it to two differnt application. one sugesstion i got from Kakan is to develop a filter driver.
Now can a filter driver be used to install a virtual device.
there are MSVAD sample drivers in DDK. are thay filter drivers?
can i use those sample codes for my work.
saad
|
|
|
|
|
Hi,
I have a line that I want to key as follows:
m_Query.Format("select Route_ID
Stage_ID,
Price,
valid_from,
valid_to,
Price_Key
from TicketPrice
where Ticket_Type = '%s'
FOR UPDATE", m_selected_id);
However I get C2001 newline in constant messages from the compiler. Anyone know the line continuation symbol?
Ger
|
|
|
|
|
Ger Hayden wrote: Anyone know the line continuation symbol?
You can either use the backslash character like:
m_Query.Format("select Route_ID \
Stage_ID, \
Price, \
valid_from, \
valid_to, \
Price_Key \
from TicketPrice \
where Ticket_Type = '%s' \
FOR UPDATE", m_selected_id); or enclose each string in quotes like:
m_Query.Format("select Route_ID "
"Stage_ID, "
"Price, "
"valid_from, "
"valid_to, "
"Price_Key "
"from TicketPrice "
"where Ticket_Type = '%s' "
"FOR UPDATE", m_selected_id);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thanks David,
Both forms work perfectly
GER
Ger
|
|
|
|
|
I've built a fairly simple MFC project, dialog based, that talks to a USB GPS device. The program uses a second thread to receive data at a 1-second rate and display the information in text form. When a data packet is received, the worker thread sends a message to the DlgWindow to tell it to get the new information. The call is:
if (pThis->m_hWndPost)<br />
::PostMessage (pThis->m_hWndPost, pThis->m_nMessageID, 0, 0);<br />
This works correctly in the Debug version of the project. However, when the Release version is built, the second call to ::PostMessage() crashes. I've isolated that code, and if I don't call the message post, no problem (of course, the DlgWnd never gets the new data). If I trap the message at the responding function in the DlgWnd, it crashes.
One work-around: if I set the compiler options to build using the debug libraries, either stand-alone or with shared MFC DLL, the problem goes away. I can't find that I have any corrupted libraries (and no reason to suspect).
Has anyone ever seen this problem before? Any ideas what I'm doing wrong? Turning off optimizations has no effect, either.
Thanks,
Mike
|
|
|
|
|
In debug mode, compiler takes care of things like initialization.
Check if all variables used are properly initialized.
Use NULL check before using pointers.
This is just a try. I'm not sure , why crash is happening.
|
|
|
|
|
Hi EveryOne!,
I will add code later, but I am having a problem with member variables. As you will see in the code the variables are being created and ClassWizard recognizes them. However, when I try to access them in the .CPP file they aren't working (I can add events from class wizard for them). I.E. I copy the variable from it's definition in the header file place it where I need it in the .CPP file and place a . (dot) after it, but it does not provide me a list of member functions that should be available. It does nothing. There is one exception and that is the m_CalUICCombo it works fine. The m_FySelected (also a ComboBox) does not work? Following is the Header file followed by the .cpp file. To keep this post down I've only inserted the relavant parts. Has anyone every run into this problem and if so what did you do to fix it?
Many Thanks in advance...
Charlie
<br />
class CECalAppendixIForm : public CFormView<br />
{<br />
protected:<br />
CECalAppendixIForm();
DECLARE_DYNCREATE(CECalAppendixIForm)<br />
<br />
public:<br />
enum { IDD = IDD_APPENDIXI_FORM_VIEW };<br />
CComboBox m_FySelected;<br />
CLabel m_SelectedItemsLabel;<br />
CLabel m_AppendixILabel;<br />
CComboBox m_CalUICCombo;<br />
<br />
public:<br />
SYSTEMTIME ct;<br />
<br />
<br />
CImgViewerDoc* GetDocument();<br />
CString csHdrLine;<br />
public:<br />
<br />
public:<br />
virtual void OnInitialUpdate();<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnDraw(CDC* pDC);<br />
<br />
protected:<br />
virtual ~CECalAppendixIForm();<br />
#ifdef _DEBUG<br />
virtual void AssertValid() const;<br />
virtual void Dump(CDumpContext& dc) const;<br />
#endif<br />
<br />
afx_msg void OnCloseupCalUIC();<br />
afx_msg void OnCloseupFySelected();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
<br />
IMPLEMENT_DYNCREATE(CECalAppendixIForm, CFormView)<br />
<br />
CECalAppendixIForm::CECalAppendixIForm()<br />
: CFormView(CECalAppendixIForm::IDD)<br />
{<br />
}<br />
<br />
CECalAppendixIForm::~CECalAppendixIForm()<br />
{<br />
}<br />
<br />
void CECalAppendixIForm::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CFormView::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_FYSELECTED, m_FySelected);<br />
DDX_Control(pDX, IDC_SELECTITEMS, m_SelectedItemsLabel);<br />
DDX_Control(pDX, IDC_APPENDIXI, m_AppendixILabel);<br />
DDX_Control(pDX, IDC_CALUICOMBO, m_CalUICCombo);<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CECalAppendixIForm, CFormView)<br />
ON_CBN_CLOSEUP(IDC_CALUICOMBO, OnCloseupCalUIC)<br />
ON_CBN_CLOSEUP(IDC_FYSELECTED, OnCloseupFySelected)<br />
END_MESSAGE_MAP()<br />
<br />
#ifdef _DEBUG<br />
void CECalAppendixIForm::AssertValid() const<br />
{<br />
CFormView::AssertValid();<br />
}<br />
<br />
void CECalAppendixIForm::Dump(CDumpContext& dc) const<br />
{<br />
CFormView::Dump(dc);<br />
}<br />
#endif //_DEBUG<br />
<br />
CImgViewerDoc* CECalAppendixIForm::GetDocument()
{<br />
m_pDocument->IsKindOf(RUNTIME_CLASS(CImgViewerDoc));<br />
return (CImgViewerDoc*)m_pDocument;<br />
}<br />
<br />
void CECalAppendixIForm::OnDraw(CDC* pDC) <br />
{<br />
SetScrollSizes(MM_TEXT, CSize(1200,1200));
CImgViewerDoc* pDoc = GetDocument();<br />
pDoc->csHdrLine = "APPENDIX I";<br />
pDoc->UpdateAllViews(this);<br />
}<br />
<br />
void CECalAppendixIForm::OnCloseupCalUIC() <br />
{<br />
}<br />
<br />
void CECalAppendixIForm::OnInitialUpdate() <br />
{<br />
CFormView::OnInitialUpdate();<br />
<br />
CSize sizeTotal;<br />
<br />
sizeTotal.cx = 250;<br />
sizeTotal.cy = 100;<br />
SetScrollSizes(MM_TEXT, sizeTotal);<br />
<br />
m_SelectedItemsLabel.SetWindowText("There are No Input Item(s) required for this Appendix.");<br />
m_AppendixILabel.SetTextColor(RGB(0,100,130));<br />
m_AppendixILabel.SetFontName("Times New Roman");<br />
m_AppendixILabel.SetFontSize(14);<br />
m_AppendixILabel.SetFontBold(FALSE);<br />
m_AppendixILabel.SetFontUnderline(FALSE);<br />
m_AppendixILabel.ShowWindow(SW_SHOW);<br />
}<br />
<br />
void CECalAppendixIForm::OnCloseupFySelected() <br />
{<br />
<br />
}
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Without having to wade through all of the code, are you having trouble with IntelliSense?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Let me see if I can make the problem a little more clear. When I go to my OnDraw function in the source file and put in m_CalUICCombo. I get a scrollable list box of the functions/variables I can access for that combobox. When I type m_FySelected. I do not receive the scrollable list box giving me those choices for that combobox. I hope this will make it a little more clear what I am having a problem with. So I am not sure if that would be a problem with intellisense? Any further advice would be appreciated.
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Charlie Curtis wrote: So I am not sure if that would be a problem with intellisense?
It is. See if this helps.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Appreciate your time and effort. I followed the link and found the information very useful for future reference. however, for the problem I had today it turns out that my .ncb, .aps, and .clw files got corrupted. I deleted them and reopened my project rebuilt the class wizard and all is well. Thanks again for the info.
Charlie
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Charlie Curtis wrote: ...my .ncb, .aps, and .clw files got corrupted. I deleted them and reopened my project rebuilt the class wizard and all is well.
Yes, that is a common problem, too.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Please forgive my bad English first.
I changed the number of arguments of one of exposed methods of an old MFC activeX control. Then I just can't call it any more either in VB or ActiveX Control Test Container.
Here are the steps:
1).
I built a MFC activeX control with one of its exposed functions requiring 1 arguments. I registered the control and built a test VB application and it was OK.
2).
Then I changed that function to having 2 arguments and built the control again. And I also registered it again.
3).
The I changed calling code in the test VB application accordingly. But it just failed to call the function by remind me "Invalid number of arguments".
Any help will be greatly appreciated!
|
|
|
|
|
I think I found an IMPORTANT message. It's a warning when I compile the new MFC control in VC 6.0:
: warning C4002: too many actual parameters for macro 'DISP_FUNCTION'
I think this the very reason of the problem. But I have manually changed the method declarations in all the places.
Why is there this compiling WARNING?
|
|
|
|
|
Michael Tang wrote: : warning C4002: too many actual parameters for macro 'DISP_FUNCTION'
It says you have added one additional parameter in macro defn.
Make your macro defn look like one following
DISP_FUNCTION(mycorntrolclass, "MyMethod", MyMethod, VT_EMPTY, VTS_PI4 VTS_PI4)
make sure you activex builds without any warning.
Add its reference to your client program again.
|
|
|
|
|
prasad_som, A thousand thanks to you!
You just hit it, Now it's solved by killing the redundant comma.
I had checked the macro difinition I changed for so many times, but I just omitted the comma.
|
|
|
|
|
my pleasure
|
|
|
|
|
We have added the stackwalker.cpp program to our application to generate callstack report.
This is working fine in the development environment and the stacktrace is getting created.
But when we copy the executable to a separate windows system where there is no development environment like visual studio installed, the stacktrace is not getting created. Is this error
due to some missing dll files in the isolated system where we dont have visual studio installed
or do we have to make some changes in the way we are compiling and building the application.
Any suggestions would be of immense help.
|
|
|
|
|