|
Override WM_LBUTTONDOWN Window Message.
use this Small piece of Code to get the current pixel color
void CWindowNameDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
COLORREF ref=dc.GetPixel(point);
CDialog::OnLButtonDown(nFlags, point);
}
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
hello , iam using this command
hr=pIXMLDOMElement->put_text(_T("text"));
it is returning the following error
error C2664: 'put_text' : cannot convert parameter 1 from 'char [5]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Rahul Agarwal
|
|
|
|
|
_T is for strings that should be the same size as your compile options: char (byte-oriented character sets) if _UNICODE is not defined, wchar_t (word-oriented character set UCS-2/UTF-16, loosely called 'Unicode' in the documentation) if it is defined.
COM always uses UCS-2/UTF-16 strings. This particular call takes a BSTR argument, which is a special form of string with a prefix indicating the length of the string. I suggest using either the _bstr_t or CComBSTR class to wrap the data:
hr = pIXMLDOMElement->put_text( CComBSTR( L"text" ) ); Note the L prefix. This tells the compiler to generate a wide-character (word-oriented) string.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is it possible?
Can I set different fonts (size, font-family) in CTreeView?
Thanks in advance, bilas
|
|
|
|
|
You can use custom draw[^] to draw the items in a tree view in any way you want.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thank you, Mike. I'll try it right now.
I'm not advanced in programming, but I trying..
|
|
|
|
|
Hi, Mike. Thanks a lot for yor help. I've just tried to understand the project, that you had told about. I downloaded code (custdtv.exe). But it's not easy enough for me to got it.
I couldn't understood the next function enough:
long handleCustomDraw(HWND hWndTreeView, LPNMTVCUSTOMDRAW pNMTVCD);
Can you help me with more simple example. I need an example, that may set different fonts in my CTreeView.
My regards, bilas.
|
|
|
|
|
I am in the process, of creating a simple application.
in simple C++ (No MFC, bits of STL).
I basically Have one class . the Main Class (Similar to MFC)
on initialization of Main Class. The Window should be created as in the Main Constructor.
If I do like this, The Application fails while Creating The Window.
The Class Registers, The CreateWindow Fails at RunTime. with the Error, The Memory could not be written.
However I bring the CreateWindow() Function within the WinMain The Code works fine.
Can you tell me Why is this so???
My WinMain runs something like this
Main* the_app;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int nCmdShow)
{
the_app = new Main(hInstance,nCmdShow);
BOOL bRet;
while( (bRet = GetMessage( &(the_app->msg), NULL, 0, 0 )) != 0 )
{
if (bRet == -1)
{
}
else
{
TranslateMessage(&(the_app->msg));
DispatchMessage(&(the_app->msg));
}
}
return (int)((the_app->msg).wParam);
}
while the Main class has something like this
class Main
{
public:
HINSTANCE hInstance;
HDC Hdc;
// list<drawable_object> D_objects;
HWND Hwnd;
MSG msg;
WNDCLASSEX wc;
HICON hi;
ATOM main_item;
Main(HINSTANCE,int);
void Destroy();
void update_HWND(HWND with_this);
};
Main::Main(HINSTANCE Hinstance,int nCmdShow)
{
hInstance = Hinstance;
hi = LoadIcon(hInstance,"ICON1");
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = hi;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = "IDR_MY_MENU";
wc.lpszClassName = "MainWClass";
wc.hIconSm = NULL;
if (!(main_item=RegisterClassEx(&wc))){
MessageBox(GetForegroundWindow(),"Register Class HAs Failed","INFO",MB_OK);
}
Hwnd = CreateWindow((LPCTSTR)main_item,"Shri-Ganesha",WS_CAPTION|WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,NULL,NULL);
if (!Hwnd)
{
MessageBox(GetForegroundWindow(),"Create Window has failed","INFO",MB_OK);
exit(1);
}
ShowWindow(Hwnd,nCmdShow);
}
|
|
|
|
|
Where is your MainWndProc Function i would like to see it defination
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I have 2 File
CreateWindow.cpp (Containing MainWndProc,WinMain & HelpDialogProc)
The Second File(Main.cpp) Contains Main::Main ( The Construtor) and a Reference to MainWndProc
MainWndProc --- (CreateWindow.Cpp)
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
the_app->update_HWND(hWnd);
RECT rec;
POINTS ClientA;
POINTS ClientZ;
HDC hdc = GetDC(hWnd);
PAINTSTRUCT ps;
int rval;
static std::list<points> _pts;
list <points> :: iterator p;
switch (msg)
{
case WM_DESTROY:
the_app -> Destroy();
break;
case WM_LBUTTONDOWN:
ClientA = MAKEPOINTS(lParam);
_pts.push_back(ClientA);
MoveToEx(hdc,ClientA.x,ClientA.y,NULL);
break;
case WM_MOUSEMOVE:
if (wParam & MK_LBUTTON)
{
ClientZ = MAKEPOINTS(lParam);
p = _pts.end();
p--;
if ((p->x > 0) && (p->y) > 0)
LineTo(hdc,ClientZ.x,ClientZ.y);
else
MoveToEx(hdc,ClientZ.x,ClientZ.y,NULL);
_pts.push_back(ClientZ);
}
// Track Mouse Event. THis has been parenthsized because the c++ doesn't allow any declaration within teh case
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
tme.dwHoverTime = HOVER_DEFAULT;
TrackMouseEvent(&tme);
}
break;
case WM_MOUSELEAVE:
case WM_LBUTTONUP:
POINTS tmp;
tmp.x = 0;
tmp.y = 0;
_pts.push_back(tmp);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_FILE_EXIT:
MessageBox(NULL,"You are exitting","Ganesha",MB_OK);
DestroyWindow(hWnd);
break;
case ID_HELP_SHOW:
if (!IsWindow(hHelpDialog))
{
hHelpDialog = CreateDialog(the_app->hInstance,"Dialog1",hWnd,HelpDialogProc); // HelpDialogProc is another Proc
ShowWindow(hHelpDialog, SW_SHOW);
}
break;
}
break;
case WM_PAINT:
{
int flag = 0;
hdc = BeginPaint(hWnd,&ps);
for (p = _pts.begin();p != _pts.end();p++)
{
if (p->x > 0 && p->y > 0)
{
if (flag){
LineTo(hdc,p->x,p->y);
}
else
{
MoveToEx(hdc,p->x,p->y,NULL);
}
flag = 1;
}
else
{
flag = 0;
}
}
EndPaint(hWnd,&ps);
break;
}
default:
return DefWindowProc( hWnd, msg, wParam, lParam );
}
return 0;
}
|
|
|
|
|
Hi !
My problem : I created an application which implements 3 splitter windows. The problem is that I do not receive Update command UI messages for one of the views , thus causing my toolbarbuttons to stay disabled to begin with.
What is the problem ?
Please help,
Rubi
|
|
|
|
|
When a view has splitter windows present, by default all the On_COMMAND and ON_UPDATE_COMMAND_UI handler calls go through to the first view class in Pane1. You will have to write some kind of handler which allows these calls to be passed through to the active splitter view.
If you vote me down, my score will only get lower
|
|
|
|
|
|
when i install the LSP code Sample of the MSDN
my internet explorer cant establish any internet connection.
if any one know why this problem occurs and how to solve it please send me .
also if any one have code any other code sample that doesnt contain this problem please send it to me .
thank you
|
|
|
|
|
how can i add a listview contrl into a dialog box in sdk
without using mfc how can i add values into it
regards Tijo
|
|
|
|
|
i using serial Class for my vc++ project.
i check sometime this port is on or off.
(it more than one port) it may be 1 to 3 port.
if port is close(power off),my project is slow.
how can i control my project more faster.
code here
---------
// Serial.cpp
#include "stdafx.h"
#include "Serial.h"
CSerial::CSerial()
{
memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
m_hIDComDev = NULL;
m_bOpened = FALSE;
}
CSerial::~CSerial()
{
Close();
}
BOOL CSerial::Open( int nPort, int nBaud )
{
if( m_bOpened ) return( TRUE );
char szPort[15];
char szComParams[50];
DCB dcb;
wsprintf( szPort, "COM%d", nPort );
m_hIDComDev = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
if( m_hIDComDev == NULL ) return( FALSE );
memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
COMMTIMEOUTS CommTimeOuts;
CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;
CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
CommTimeOuts.ReadTotalTimeoutConstant = 0;
CommTimeOuts.WriteTotalTimeoutMultiplier = 0;
CommTimeOuts.WriteTotalTimeoutConstant = 5000;
SetCommTimeouts( m_hIDComDev, &CommTimeOuts );
wsprintf( szComParams, "COM%d:%d,n,8,1", nPort, nBaud );
m_OverlappedRead.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
m_OverlappedWrite.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
dcb.DCBlength = sizeof( DCB );
GetCommState( m_hIDComDev, &dcb );
dcb.BaudRate = nBaud;
dcb.ByteSize = 8;
unsigned char ucSet;
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 );
if( !SetCommState( m_hIDComDev, &dcb ) ||
!SetupComm( m_hIDComDev, 10000, 10000 ) ||
m_OverlappedRead.hEvent == NULL ||
m_OverlappedWrite.hEvent == NULL ){
DWORD dwError = GetLastError();
if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
CloseHandle( m_hIDComDev );
return( FALSE );
}
m_bOpened = TRUE;
return( m_bOpened );
}
BOOL CSerial::Close( void )
{
if( !m_bOpened || m_hIDComDev == NULL ) return( TRUE );
if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
CloseHandle( m_hIDComDev );
m_bOpened = FALSE;
m_hIDComDev = NULL;
return( TRUE );
}
BOOL CSerial::WriteCommByte( unsigned char ucByte )
{
BOOL bWriteStat;
DWORD dwBytesWritten;
bWriteStat = WriteFile( m_hIDComDev, (LPSTR) &ucByte, 1, &dwBytesWritten, &m_OverlappedWrite );
if( !bWriteStat && ( GetLastError() == ERROR_IO_PENDING ) ){
if( WaitForSingleObject( m_OverlappedWrite.hEvent, 1000 ) ) dwBytesWritten = 0;
else{
GetOverlappedResult( m_hIDComDev, &m_OverlappedWrite, &dwBytesWritten, FALSE );
m_OverlappedWrite.Offset += dwBytesWritten;
}
}
return( TRUE );
}
int CSerial::SendData( const char *buffer, int size )
{
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
DWORD dwBytesWritten = 0;
int i;
for( i=0; i
|
|
|
|
|
why don;t you make your checking part a thread for each port your checking.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
i want to port is open or close.
example................
if (serial.Open(5,38400))
{
MessageBox("Port 5 is open");
serial.Close();
}
com 5 is network serial com port.
VLINX ESP Server make virtual com port for my computer.
when com5 is power on,i open com5(OK).
when com5 is power off,i open com5(very slow my application)
|
|
|
|
|
Have you tried setting these timeouts to smaller numbers.
CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;
CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
CommTimeOuts.ReadTotalTimeoutConstant = 0;
CommTimeOuts.WriteTotalTimeoutMultiplier = 0;
CommTimeOuts.WriteTotalTimeoutConstant = 5000;
|
|
|
|
|
i was tried as u say but i don't success..
|
|
|
|
|
hello can u tell me how 2 create xml in vc++ using MSXML 3.0
thx
Rahul Agarwal
|
|
|
|
|
Please Read Documentation of IXMLDocument in your local copy of MSDN ,you will get all your answers to your problem there.
Or you can manully create XML (by following XML standards ) through your coding as you have to pass it Remote Server.
During receiving and parsing the XML,use the coding I have given to you in my last POST to you,
here[^]
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello,
Is there an easy way to port an ActiveX control (partially based on MFC) back to a plain MFC control?
I'm well aware the good side of ActiveX controls, but here, due to the versioning nightmare and also due that it is poorly written, I will be difficult to continue to use as-is. (Written Quick &Dirty by a programmer that left the company and now I need to maintain it .
Also, adding new interfaces, or even changing the current interfaces this control has, may corrupt its use on other projects that must run in parallel.
For this, I thought that the best is move back to MFC, so every project has its tailored control and it will not deppend on how/where the ActiveX control is registered.
The ActiveX control is a simple charting control that allows to display constellation, also works as a "scope" control.
Any hint?
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Hi all,
Iam very new to windows programming stuff.
I require to add resolution modes in display settings of the desktop on Windows98 plateform.
Where as in windows 2K/XP/NT v have facility to check and uncheck the option " Hide the modes that this monitor cannot display" which adds many resolution modes to change for all display cards..or.. change the value 0/1 of "pruning mode" key in registry path HKLM\SYSTEM\CONTOLSET001\SERVICES\IALM\DEVICE0 ( intel graphics card).
i keep on changing cards like ATI,Nvedia,matrox,etc....
but in windows 98 there no facility in registry as such.
note:
On WIN98 i found one Modes folder in regisry HKLM\SYSTEM\CURRENTCONTROLSET\CLASS\DISPLAY\active driver e.g 0000\Modes
here i can see arround 37 resolution modes in which some are not shown in display settings.
i would like to add these modes into display settings options and customer to choose from that.
if anybody knows requested to help.
ur member
|
|
|
|
|
My application can able to open the *.xlc format file and shows the content in the file.
My Question was, How can I open the *.xlc file from windows explorer Open With option? How can I pass this *.xlc file parameter to the file to open the file with my application.
Please help me in this...
|
|
|
|
|