|
Hi
I have a very little problem, but still it is a problem so please if you know any solution write me back.
How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2.
thanks!
|
|
|
|
|
2^4 = 0010 ^ 0100 = 0110 = 6 which would explain why you are getting 6 as a result.
I would suggest using the following function located in math.h
double pow( double x, double y );
Sean Cody
|
|
|
|
|
There isn't an exponential operator in C. However, you do have the pow function.
Sort of sucks...
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
^ is the XOR operator in C. As others have said there is no raise-to-power operator.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I am drawing something on the OnPaint or OnDraw Method which some times go beyound the Client Area so Scroll Bar activated. After that user can do any thing.
Through any event I want to convert whole client screen in to BMP. Problem is that when I took the Client Window Handle it is not giving the Data which is beyond theClient Screen (i.e., currently not visible but visible through scrolling).
What I do to grab whole thing which I draw on the Client View.
I am looking for any Code . . . any idea . . . any . . .
Thanks in adnavce.
|
|
|
|
|
I would create a memory bitmap the required size, select it into a memory DC, and call OnDraw(&memory_DC). The memory bitmap will now contain the entire view, independant of the window size.
---
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The ATL declarations in stdafx.h:
// the following lines are required for ATL support
#include "atlbase.h"
extern CComModule _Module;
//#include "atlcom.h"
#include "atlapp.h"
#include "atlwin.h"
#include "atlctrls.h"
#include "shellapi.h"
#include "atlctrlx.h"
The usage of CHyperLink:
CHyperLink MyLink;
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
MyLink.SubclassWindow(GetDlgItem(hDlg,IDC_MYEMAIL));
return TRUE;
The errors:
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : warning C4003: not enough actual parameters for macro 'SubclassWindow'
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : error C2059: syntax error : '('
Any idea what I'm doing wrong?
|
|
|
|
|
I want to access some controls on a CFormview (Edit, listboxes, ...) from a DLL
So I pass a pointer to the control to the dll.
But each time when I access a pointer, I get an assert (IsWindows() fails). When debugging, the pointer seems to be valid.
What is wrong ?
Greetings,
Niko
|
|
|
|
|
Without seeing your code is hard to know, but seems to me that you're trying to use the controls before they are actually created. Having a CFormView variable is not enough, it is only after Create is called on that variable that the controls come to life.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Did you "import" the dll into your project?
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
What is the best way to use a clipping region that is centered within the client frame that I could use to display graphics and perform hit testing plus keep a caret within this region?
I'v been reading my sdk doc's on gdi+, just havn't figured it out yet. Any suggestions on reading material? I heard Feng Yuan's book was good.
|
|
|
|
|
Feng Yuans's book is very good, But I do not think that there is anything in his book about hittesting.
What you can do is call the SetCapture function which will capture the mouse for the target window that wants to capture and contain the mouse. Then you can handle the WM_NCHITTEST message for that window. This message is called every time a mouse message is generated such as a WM_MOUSEMOVE, WM_LBUTTONDOWN and even the NC versions of all of these messages. There are about 20 altogether.
Inside of your WM_NCHITTEST handler you can determine the current position of the cursor. Use this data to determine if the cursor is in the region that you want to use to contain the cursor. Use the PtInRegion function. If the cursor is outside of the region call the SetCursorPos function to clip the position of the cursor.
|
|
|
|
|
Does anybody know the code for C++ 6.0 to allow it to search for a certain character in a sentence.
Ex: My name is Mike
Search for character M:
If found it tell me how many you found
If didn't found it tell me cannot find.
Thanks
|
|
|
|
|
Try learning some C, C++ - mostly data structures and some algorithms like KMP and Boyer-Moore - and then use Visual C++...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
CString::Find does some of the work for you.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
?
Any ideas? Any code? I can use the arrow keys, but
how can I use the tab key to navigate through a
MsFlexGrid control?
Please, please, any response any one can give me will
be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
I don't know about MsFlexGrid,but in CP there are nice grids,check them,maybe they are useful for this task.
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
under MDI, an icon IDR_MAINFRAME is created. how can i load it to the mainframe so that when execute the program, the icon i created can appear on the mainframe?
can this bedone too for childframe?
|
|
|
|
|
In the InitInstance() of your application find this lines:
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
In place of "IDR_MAINFRAME" you can put yuor own icon.
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
t've tried this earlier on. but unsuccessful. does the OS affect the way the application works? i am now programming under XP OS.
it seems to me that when i change the IDR_MAINFRAME in the resource, it will still load the default MFC icon. how do i associate the icons i created to the project?
|
|
|
|
|
once you create your icon, save it to your resource directory. Then from the resource view tab, select IDR_MAINFRAME, then right click. A popup menu will show then select properties and you should see the properties dialog for IDR_MAINFRAME. The edit box at the bottom labeled file name needs to point to the path of the new icon in your resource directory. Close the dialog then your icon will be associated with IDR_MAINFRAME.
Cheers
Jay Beckert
|
|
|
|
|
once you create your icon, save it to your resource directory. Then from the resource view tab, select IDR_MAINFRAME, then right click. A popup menu will show then select properties and you should see the properties dialog for IDR_MAINFRAME. The edit box at the bottom labeled file name needs to point to the path of the new icon in your resource directory. Close the dialog then your icon will be associated with IDR_MAINFRAME.
Cheers
Jay Beckert
sorry for the re-reply My typo's made it hard to understand.
|
|
|
|
|
I think there is a bug in the autogenerated code, so if you try modifying your PreCreateWindow function to look like below, it should work.
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
i have tried the above 3 ways by juz using a totally new and empty MDI application. but it doesn seem to work. only the icon in the ABOUT dialog changes. how can i actually load the icon into the mainframe and the child frame.
i have been trying these for weeks. hope some1 can help mi
|
|
|
|
|
Please, help me! I have external device, which connects with comm-port.
I send to device the number, after it signaled it send to computer some signal;
how can i receive this signal? in case, if device is nonsignaled, how can i wait
it for five sec, and break the waiting operation?
What do i need to write to this code, in the end of it?
I know all abot WaitCommEvent and WaitForSingleObject, but i don't know
how to use it. WaitForSingleObject doesn't work with EVENT, or i don't know
how to use it
HANDLE port;
DWORD bc;
DCB dcb;
char buffer[100];
char *buf_out="50";
DWORD dwBlockSize=512;
void *szBuffer;
int send=255;
ZeroMemory(&dcb,sizeof(DCB));
strcpy(buffer,"baud=1200 parity=N data=8 stop=1");
BuildCommDCB((char*)&buffer,&dcb);
dcb.fRtsControl = RTS_CONTROL_ENABLE;
port=CreateFile("COM1",
GENERIC_READ|GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
GetCommState(port,&dcb);
SetCommState(port,&dcb);
HeapFree(GetProcessHeap(),0,&dcb);
szBuffer = malloc(dwBlockSize);
memset(szBuffer, send, dwBlockSize);
// Sending number for device
WriteFile(port,szBuffer,sizeof(szBuffer),&bc,NULL);
free(szBuffer);
// Wait for signal for five sec
CloseHandle(port);
|
|
|
|