|
Off the top of my head (i.e. untested) do something like this:
#define IOOP_READ 1
#define IOOP_WRITE 2
#define CK_CONTAINING_RECORD( PTR, TYP, FLD ) \
( (TYP*)( (byte*)(PTR) - (byte*)(&((TYP*)0)->FLD) ) )
class MyFile;
class MyOL : public OVERLAPPED {
public:
virtual ~MyOL( void ) {
if( Buff ) delete [] Buff;
}
MyFile *File;
DWORD Op;
DWORD Cnt;
char *Buff;
OVERLAPPED Ptr( void ) { return(&Internal); }
};
class MyFile {
protected:
HANDLE hnd;
static void CALLBACK iocr( DWORD ERR, DWORD CNT, OVERLAPPED *OL ) {
if( !OL ) return;
MyOL *ol = CK_CONTAINING_RECORD(OL, MyOL, Internal);
ol->Cnt = CNT;
ol->File->OnIOC(ol);
delete ol;
}
void onIOC( MyOL *OL ) {
switch( OL->Op ) {
case IOOP_READ : ...
case IOOP_WRITE : ...
}
}
public:
bool ReadEx( DWORD SZ ) {
if( !SZ ) return(false);
MyOL *ol = new MyOL();
ol->Op = IOOP_READ;
ol->File = this;
ol->Buff = new char[SZ];
return( ReadFileEx(hnd, ol->Buff, SZ, ol->Ptr(), iocr) );
}
bool WriteEx( DWORD SZ, void *BUFF ) {
if( !SZ || !BUFF ) return(false);
MyOL *ol = new MyOL();
ol->Op = IOOP_WRITE;
ol->File = this;
ol->Buff = new char[SZ];
memcpy(ol->Buff, BUFF, SZ);
return( WriteFileEx(hnd, ol->Buff, SZ, ol->Ptr(), iocr) );
}
};
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hello...
This is very guru like solution...
Big Thx, greets from germany...
|
|
|
|
|
Hi,
I hope someone can help me with the following problem:
I have to download several web pages and search for a special number or text in this sites.
If the number or the text is found, the adress of the page should be displayed.
So, now my problem is that I don't know how to download a page? Does anyone have a sample?
The other problem is that before this web pages can be displayed in IE or Firefox you have to enter a username and password!
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
Daniel Strigl wrote:
So, now my problem is that I don't know how to download a page? Does anyone have a sample?
Try This
http://www.codeproject.com/internet/amhttputils.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello friend,
i want a help regarding retrieving data from a Window's Edit boxes.
The situation is like this:There is a window( seems to be a dialog box produced by some Application). The window is containing many sub windows(controls inside it). my requirement is to read the data present in those controls/sub windows/edit boxes.
The extent to which i have come is, able to get a handle to that edit box( of class CWND). with that handle it is also working if i try to enable/disable all windows/controls present in a maibn parent window . if i am using the function ::GetWindowText(), i am not getting the text in that edit box( where as for all button window i am getting their captions like &OK,&Edit e.t.c).
please tell me how to access the text present in the editboxes.
and my problem is like this said above in last paragraph.
|
|
|
|
|
please post the code where you are using GetWindowText() because it should work.
CEdit* pEdit = ;
CString strText = "";
pEdit->GetWindowText(strText);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
please validate the code here if sth is wrong. Only the case for edit box controls it is not working , i am tinking if any locking they have done there. have tried many other options also all of them commented in the below code.
the main window therei is 'System Event" from which i anm trying to read the contents of all its sub windows( edit boxes e.t.c)
void WManip(CWnd *WndActiveChild ,CWnd *WndParent)
{
CWnd * WndActiveChildRead;
CEdit *WndEdit;
LPTSTR EditText;
COleDataObject ClipObj;
tagSTGMEDIUM *strVar;
LPCTSTR lpctFormat;
int ControlID,WinCount = 0;
CString rString,temprString,text;
WndActiveChild->SetForegroundWindow();
WndActiveChild->SetFocus();
// WndActiveChild->OpenClipboard();
// if (( (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString) ) != 0 )
// (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString);
// if (rString != "")
// AfxMessageBox("some thingn hapend "+rString);
ControlID = WndActiveChild->GetDlgCtrlID();
WndActiveChild->GetWindowText(rString);
AfxMessageBox(rString);
//WndEdit = WndActiveChild ;
// ClipObj.AttachClipboard();
// strVar = new tagSTGMEDIUM;
// ClipObj.GetData(CF_TEXT, strVar,NULL);
// WndActiveChild ->GetLine(0,EditText);
// WndParent ->GetDlgItemText(ControlID,rString);
// temprString.Format("%s%d%s", (LPCTSTR) rString,ControlID, (LPCTSTR)EditText ); //(LPCTSTR) rString,
AfxMessageBox(temprString);
// the following code is just for testing i have put.
if (rString.Compare("&Edit") == 0)
{
WndActiveChild->PostMessage(WM_LBUTTONDOWN,0,0);
Sleep(50);
WndActiveChild->PostMessage(WM_LBUTTONUP,0,0);
// WndParent->CheckDlgButton(i,1);
}
// WndActiveChild->EnableWindow(false);
WinCount ++;
}
void CConfigTool_AutomateDlg::OnOK()
{
int i,WinCount = 0;
CString rString,temprString,text;
CEdit EControl;
CWnd * pActWindow,*pActChildWindow,*pActChild1Window, *pActChild2Window ;
// pActWindow = CWnd::GetActiveWindow();
pActWindow = CWnd::FindWindow(NULL ,"System Event");
pActWindow->SetForegroundWindow();
// pActWindow->ShowWindow(SW_SHOWMAXIMIZED);
pActChildWindow = pActWindow->GetTopWindow();
while (pActChildWindow != NULL)
{
WinCount ++;
pActChild1Window = pActChildWindow->GetTopWindow();
while(pActChild1Window != NULL)
{
WinCount ++;
/* pActChild2Window = pActChildWindow->GetTopWindow();
while(pActChild2Window != NULL)
{
WinCount ++;
WManip(pActChild2Window,pActChild1Window);
pActChild2Window = pActChild2Window->GetNextWindow(GW_HWNDNEXT);
} */
WManip(pActChild1Window,pActChildWindow);
pActChild1Window = pActChild1Window->GetNextWindow(GW_HWNDNEXT);
}
WManip(pActChildWindow,pActWindow);
pActChildWindow = pActChildWindow->GetNextWindow(GW_HWNDNEXT);
}
// temprString.Format("%s%d", "Total number of windows" , i);
// AfxMessageBox(temprString);
if (CanExit())
CDialog::OnOK();
}
|
|
|
|
|
did you really think that i was going to read that entiere code ?
first of all, if you one anyone reading and validating it, put it into <pre></pre> tags to be more readable. moreover, i just asked for the code where you were using the GetWindowText(), not the whole one... so, please use the [modify] link at the bottom of your post...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
did you really think that i was going to read that entiere code ?
Cool Down brother....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hum, yes, i know i must calm down, but it's really bothering to see how many people post so useless questions...
we are obliged to ask one more question and overload the servers to try to understand what the guy wanted us to solve...
OT: i'm really really really sorry for series II && III ; i'm ending my classes in one week, and i have to prepared hard my next job (and i'm not even sure where i will work at this date !)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
: i'm really really really sorry for series II && III ; i'm ending my classes in one week, and i have to prepared hard my next job
No Problem Buddy, I will Manage
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
please look into the below code equivalent to then pvevious one after removing all the redundant lines. please let meknow about: given any window how to obtain information of all the data present in the window.
please suggest me a method or any example code to do the following
requirement is as below:
input: window
Output:
details of various items present in the window and their content as far as possible.
Maincallingfunction()
{
WND * wndparent,*wndchild1,*wndchild2;
wndparent = Findwindow("WindowName");
cwndchild1= wndparent->GetTopWindow();
while(wncdhild1!= NULL)
{
GetWindowContent(wndchild,wndparent);
wndchild2= wndchild1->GetTopWindow();
while(wncdhild2!= NULL)
{
GetWindowContent(wndchild,wndparent);
wndchild2= wndchild2->GetNextWindow()
}
wndchild1= wndchild1->GetNextWindow();
}
}
void GetWindowContent(CWnd *WndActiveChild ,CWnd *WndParent)
{
CWnd * WndActiveChildRead;
CEdit *WndEdit;
LPTSTR EditText;
COleDataObject ClipObj;
tagSTGMEDIUM *strVar;
LPCTSTR lpctFormat;
int ControlID,WinCount = 0;
CString rString,temprString,text;
// code starting from here
WndActiveChild->SetForegroundWindow();
WndActiveChild->SetFocus();
ControlID = WndActiveChild->GetDlgCtrlID();
WndActiveChild->GetWindowText(rString);
AfxMessageBox(rString);
}
-- modified at 7:13 Wednesday 14th September, 2005
|
|
|
|
|
teja_tejaswi wrote:
WND * wndparent,*wndchild1,*wndchild2;
wndparent = Findwindow("WindowName");
cwndchild1= wndparent->GetTopWindow();
If you trying to retrieve content from Window/Edit box thats belong to some other process... then GetWindowText(..) api will not work..
You have to use WM_GETTEXT and WM_GETTEXTLENGTH message to reterive the text of that window.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
You cant read the edit box because it not in you process however do not fret
lResult = SendMessage(
// returns LRESULT in lResult
(HWND) hWndControl,
// handle to destination control
(UINT) WM_GETTEXT,
// message ID
(WPARAM) wParam,
// = (WPARAM) () wParam;
(LPARAM) lParam
// = (LPARAM) () lParam;
);
Look up further documentation on the web but this will take care of your problem.
|
|
|
|
|
ky_rerun wrote:
WM_GETTEXT,
Sorry if I sound Rude.., I believe same thing is mentioned by me around 15 hr prior to your post.... Please check other comments before posting..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello,
At the moment Im writing on a code-comment macro that shall automatically generate comment-dummys for namespaces, classes, functions, etc., because I want to use my code with doxygen.
After matching with several problems Ive come to a problem I cannot solve myself.
Im using the CodeElements Interface to go through all elements and use the Comment-member of the CodeElement (eg. CodeClass) to set my comment-dummy.
In fact the problem is quite simple:
Visual Studio only assigns a comment to a CodeElement when it is looking like that:
// bla blub
// further blubb
but not if it looks like that
/* hrhr
*/
or that
//! codecomment
It wouldnt be any problem to make comments that are accepted by doxygen, but these comments are not assigned to the CodeElement and this way are not shown in the information-window that opens when you are goind to use the function in your source.
Is there a way to change this visual studio behaviour, so it would accept a comment like this as the comment assigned to the function?
/* void JustDoingSomething()
\brief does something
*/
void JustDoingSomething();
|
|
|
|
|
Hm, just forget about it - my visual studio now also shows the other comments - no idea why this wasnt the case before...
|
|
|
|
|
when linking my vc project on vc++6.0,i got a link error.
It says:
"strmbasd.lib(wxdebug.obj):error LNK2001:unresolved symbol_imp_strrchr"
so,how to settle this problem?
thanks!
All I do I do it for you!
|
|
|
|
|
Hi all
I have this application, when ever a failure condition is encountered, i display a message box and
post a quit message to the window and exit.
but the message box is displayed only if i press on the
ALT key, i tried to change the MessageBox style to MB_TopMOST|MB_SYSTEMMODAL nothing is working for me
i want the messagebox to be displayed in foreground.
MyCode:
MessageBox(AfxGetMainWnd()->GetSafeHwnd(),"Fatal Error!!!,Application will terminate","ERROR", MB_OK|MB_ICONERROR|MB_TOPMOST);//notworking
or
MessageBox(HWND_DESKTOP,"Fatal Error!!!,Application will terminate","ERROR",MB_OK|MB_ICONERROR|MB_TOPMOST);//NOT WORKING
or
AfxMessageBox(-as above__)// not working
please help, urgent...
regards
pradish
|
|
|
|
|
What is the conditions of displaying the message box?
From which function you display the message box?
Did you try with AfxMessageBox(...) instead?
|
|
|
|
|
Hi,
only a try
::MessageBox(NULL, "Your text", "Error", MB_OK | MB_ICONERROR| ... );
HTH
Frank
|
|
|
|
|
Frank K wrote:
::MessageBox(NULL, "Your text", "Error", MB_OK | MB_ICONERROR| ... );
Yeah, this can help, but ia m afraid this wouldn't take Focus!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Respected all
I am david and very new to vc.
My query related to my previous 2 queries.
"I am displaying a Bitmap along with data on different poition of bitmap using dc.TextOut() function on a Dialog Window but when i select the 2nd bitmap from list box to display on that Dialog Window then the bitmap has been displayed but the data cant dispalyed and display an error message that a bug occurred.
I used
Invalidate()
and UpdateWindow() function but did not work.
So plz guide me .....
david
|
|
|
|
|
and what about - just a guess - calling OnPaint() ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi friends
I want to create a windows service that has an array of digits in itself;
Then I want to develop an application to interact with this windows service
Now,What do I do in this application:
The application request from windows service to return a specific inedx of array.
Please help me immediately!
I want to do all these work in VisualC++ 6.0
-- modified at 3:05 Wednesday 14th September, 2005
|
|
|
|
|