|
Use the HANDLE of the second thread as the Kernel object in WaitForSingleObject() in the first thread.
HANDLE hThread2 = CreateThread(...);<br />
WaitForSingleObject( hThread2, INFINITE);
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thanks for the reply.
Problem here is,in second thread ,only on a particular condition i need to block th e user input.the second thread should run as background process without interrupting the
first thread.
I need to block all IO operations.I'm using named pipes and overlapped IO.
in this case how to block IO.even though i set flags,after finishing the second thread,
all pending IO gets excuted.How to avoid this.Pls help
Can i use CancelIO?
Thnks
ram
|
|
|
|
|
i wana create the window but there is some problem can any one slove it
#include<afxwin.h>
#include"resource.h"
class Dialog:public CDialog
{
public:
Dialog(int n = IDD_FORMVIEW):CDialog(n)
{
}
};
class MyDialog:public CDialog
{
public:
MyDialog(int n = IDD_DIALOG1):CDialog(n)
{
}
void OnOK()
{
CWnd *p;
p = new CWnd;
MyDialog gh;
int i;
CString str;
GetDlgItemText(IDC_EDIT_PASSWORD,str);
if(str == "arif")
{
MessageBox("Welcome","Conregulation");
p->Create(0, "Hi", WS_CHILD | WS_VISIBLE,
CRect(0, 0, 20, 20), NULL, NULL,NULL);
p->ShowWindow(1);
}
else
PostQuitMessage(0);
}
void OnCancel()
{
//Create(NULL,"Hello",WS_OVERLAPPEDWINDOW,CRect(20,20,200,200),NULL);
}
};
class CPassword:public CFrameWnd
{
private:CEdit *ed;
CString str;
public:
CPassword()
{
MyDialog dlg;
LoadAccelTable(MAKEINTRESOURCE(IDR_ACCELERATOR1));
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CPassword,CFrameWnd)
END_MESSAGE_MAP()
class CPasswordApp:public CWinApp
{
public:
int InitInstance()
{ MyDialog dlg;
CString str;
MyDialog *p;
p = new MyDialog;
p->Create(IDD_DIALOG1,NULL);
p->GetDlgItemText(IDC_EDIT_PASSWORD,str);
p->ShowWindow(1);
m_pMainWnd = p;
return 1;
}
};
CPasswordApp a;
|
|
|
|
|
Yes....
Get youself a good MFC book and go from there...
|
|
|
|
|
Anonymous wrote:
i wana create the window but there is some problem...
And that problem would be? Please be more specific with your request. You'll get way more help that way. Unless there is money involved, no one likes having code dumped in front of them with a note saying "There is some problem. Can any one solve it?"
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi all,
I have 7 edit boxes, with the tab order 1-2-3-4-5-6-7
I wrote my own tab control jumping using the PreTranslateMsg as follows:
if i am at edit box 7, i jump to an other control(checkbox)
if i am at other control (spin button) i jump to edit box 1
the problem is , when i am at edit box 6 and press Tab, i see the jumping to edit box 7 and immediately i jump into the checkbox (meaning i didn't stop at editbox 7)
same as for the spin button, if i am at edit box 2 and press SHIFT+Tab(jumping backwards) i see it is jumped to edit box1 and automatically jumps to the spin control
here is the code i am using:
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
short nShiftKeyDown = GetKeyState(VK_SHIFT);
BOOL bShiftKeyDown = ((nShiftKeyDown & 0x8000) == 0x8000);
if (pMsg->hwnd == m_editAns1.m_hWnd)
{
if ( (pMsg->wParam == VK_TAB) )
{
if (bShiftKeyDown)
{
m_pParentWnd->SendMessage(UM_SET_QTXT_FOCUS);
return TRUE;
}
}
}
if (pMsg->hwnd == m_editAns5.m_hWnd)
{
if ( (pMsg->wParam == VK_TAB) )
{
if (!bShiftKeyDown)
{
m_pParentWnd->SendMessage(UM_SET_CB_FOCUS);
return TRUE;
}
}
}
return CBaseDlg::PreTranslateMessage(pMsg);
}
what am i doing wrong here?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I found out the problem!
it was getting there due to WM_KEYDOWN and WM_KEYUP
if i added the conditio pMsg->message == WM_KEYDOWN
it works
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi,
I have a problem regarding embedded dlls (managed and unmanaged).. Could you help me please ?
My problem is the following..
- my target is a Pocket PC
- I want to export an unmanaged dll that I've done using Embedded Visual C++ 4.0 and wrap it with a managed dll written in C++. My unmanaged class is :
header :
--------
#ifdef UNM
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
class DLL_API DLLUnmanaged
{
public:
DLLUnmanaged();
DLLUnmanaged(const char * const);
~DLLUnmanaged();
const char * getstring() const {return str;}
char * suffix(int n);
private:
char * str;
unsigned short len;
};
cpp:
#include
#include "stdafx.h"
#pragma warning( disable : 4091 )
#include "UnmanagedDLL.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
DLLUnmanaged::DLLUnmanaged()
{
str = (char *)LocalAlloc(0, sizeof(char));
str[0] = '\0';
len = 0;
}
DLLUnmanaged::DLLUnmanaged(const char * const str0)
{
len = (unsigned short)strlen(str0);
str = (char *) LocalAlloc(0, sizeof(char)*(len+1));
for(unsigned short i = 0; i < len; i++)
str[i] = str0[i];
str[i] = '\0';
}
char * DLLUnmanaged::suffix(int pos)
{
unsigned short suffix_length;
pos--;
if (pos < 0) pos = 0;
suffix_length = len - pos + 1;
if (suffix_length > 0)
{
char * suff = new char[suffix_length];
for(unsigned short i = pos; i < len+1; i++)
suff[i - pos] = str[i];
return suff;
} else
return 0;
}
DLLUnmanaged::~DLLUnmanaged()
{
LocalFree(str);
len = 0;
}
- I want to use the managed extensions of Visual Studio .Net like this :
#using
using namespace System;
#include
using std::cout; using std::endl;
#include "path.../UnmanagedDLL.h"
public __gc class DLLManaged // to avoid using "DLLImport"s..
{
public:
String * find_suffix(String * s, int pos)
{
int length = s->Length;
char * in_string = new char[length+1];
for(unsigned short i = 0; i
{
in_string[i] = (char)s->Chars[i];
}
in_string[length] = '\0';
DLLUnmanaged * s0 = new DLLUnmanaged(in_string);
delete [ ] in_string;
return s0->suffix(pos);
}
};
... so here is what I've done when doing it only with Visual Studio .Net. I've added to the solution (that has got the unmanaged (I took "DLL MFC") and managed (I took ".Net DLL") ) a C# windows application that simply references the managed dll. All that works fine..
but if I want to make a project like this (actually the unmanaged dll that I use is a bit more complicated that the one I gave you) for a Pocket PC I encounter a lot of problems (please don't blame me, I'm a beginner!)
I tried to do it this way. The thing is that I don't know how to make an EMBEDDED MANAGED C++ DLL...
if I do the unmanaged project with Embedded Visual C++ 4, and if I make a .Net DLL similar to the one I've given to you upper, I get errors like:
ManagedDLL error LNK2020: jeton non résolu (0A000009) _CxxThrowException
ManagedDLL error LNK2020: jeton non résolu (0A00000B) delete
ManagedDLL fatal error LNK1120: 2 externes non résolus
(sorry, I've the French version of VS .Net)
obviously the linkage goes wrong..
So..what is the thing I've to do ? could you help me please, since I'm trying to fix the problem for many days now!
thanks to pay attention to it,
Julien (IT student)
|
|
|
|
|
Hi all,
Does anybody can tell me how to change the back ground color of the printable area of the print preview view. If I override the erase background method and set the background color then the area other than the printable area background is changed. I want to just change the printable area background.
thanx in advance
thanvir
|
|
|
|
|
This is done in the void CPreviewView::OnDraw(CDC* pDC) function which can be found in viewprev.cpp line 631.
You would have to replace the existing version of this function (probably by using your own class inheriting from CPreviewView). Take a look at my enhanced print preview articles which should get you going.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Hi,
I encountered a problem in a project ,the realease version can not work properly while the debug version working well .
A cricheditctrl was created dynamically , I call the RequestResize() function in the onkeydown() for sending the EN_REQUESTRESIZE nofification message.
then I capture the EN_REQUESTRESIZE in onnotify() ,which is in the parent-window.
All above is for control the richedit control size freely.
the problem is this function can run smoothly in debug version , but not in release version!!!
who can help you , Thks ahead
Best Regards
Jun Mu
|
|
|
|
|
mujun wrote:
the problem is this function can run smoothly in debug version , but not in release version!!!
"Run smoothly", or lack thereof, is not a very specific description. What sort of problem are you seeing? Have you put in any sort of "debugging" code (e.g., message box, writing to a file) that tells you the state of things as the program is running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
What I do is let the CRichEditCtrl can auto-resize itself according to the amount of the words it contains.
I mean this function can not work in release version. In release version, the Cricheditctrl keep a fixed width forever.
do you have any other ideas?
thks
Jun Mu
|
|
|
|
|
How to make a pause in the unfolding of a function ? I'd to make a pause of 1 second.
Thx
|
|
|
|
|
Sleep
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
hello
pls help me.i am a begginer. i tried a keyboard hook program for unicode.
using my program i can display unicdoe chacter in notepad. but it is not working in word or wordpad. part of my code is given .
LRESULT CALLBACK KeyProc( int nCode, WPARAM wParam, LPARAM lParam )
{
hwndw= GetFocus();
if (nCode < 0)
{
Sleep(0);
return CallNextHookEx(m_hHookKey, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION)
{
if (lParam & 0x80000000)
{
Sleep(0);
PostMessage(hwndw, WM_KEYUP, wParam, lParam);
}
BYTE ks[256];
GetKeyboardState(ks);
WORD w;
UINT scan;
int buff;
scan=0;
ToUnicode(wParam,scan,ks,&w,buff,0);
ch_u=TCHAR(w);
if(ch_u!=8)
{
PostMessage(hwndw,WM_KEYDOWN,8,0);
}
if(ch_u>=32 && ch_u<=126)
{
switch(ch_u)
{
case 'A':
ch=3347;
'
'
'
'
}
PostMessageW(hwndw,WM_CHAR,ch,0);
is there any way to change the character i have typed ,before reaching the destination window.
thanking you
arthi
|
|
|
|
|
Dear Friends,
I got a dialog window and i am displaying a small bitmap on the window. I placed a "picture control" on the dialog and give it the path of my resource bitmap. So far so good.
We all know that bitmap is square shaped and has some background. The background of my bitmap is of same color as that of the default color of Windows 2000's Window. As such my bitmap gives illusion of "Icon" because its background color is masked with the parent window color. I developed the application on Windows 2000 machine.
But the problem is when i run my application on Windows 98 or XP. The default window color on these Operating Systems is different than that of Windows 2000. So the background color of my bitmap becoms apparent. This looks very ugly. I want to give illusion of an Icon and not bitmap.
Can you tell me some appropriate solution ? One solution in my mind is to convert my bitmap into icon. But i don't know any tool that can do so. By Bitmap has some background and i want to completely remove that background and extract the remaining image as an icon. Is there any tool available that can help me ?
Imtiaz
|
|
|
|
|
Hi,
my proposal: ownerdraw
Load the bitmap and draw them to the area
take a look at the function (-link):
LoadImage()[^]
and the parameter LR_LOADTRANSPARENT
HTH
Frank
|
|
|
|
|
You can make parts of your Bitmap transparent.
You have to use an imagelist (CImageList I think)
Then you have to make a mask of your original bitmap with only TWO colors (eg. black and white) Then the black stuff is made transparant while the white stuff is visible.
Search on CBitmap, CImageList and stuff and you'll find it.
(I have done it once, but I can't remember the whole stuff)
Hope it helps
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Rather than a bitmap, how about using an Icon. They have transparency already built-in and you can use either a static control or manual drawing.
onwards and upwards...
|
|
|
|
|
Hi,
I m trying to use InternetConnect() function to connect with FTP site...specifying valid USERNAME & PASSWORD but that always returns NULL, but when i test it using "anonymus" as USERNAME & PASSWORD it works fine.
But I want to login to the FTP using specific USERNAME & PASSWORD..
The sample snippet that is being successfull is :
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.net",INTERNET_DEFAULT_FTP_PORT,_T("anonymous"),_T("anonymous"),INTERNET_SERVICE_FTP,0,NULL);
And the code snippet that fails is :
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.net",INTERNET_DEFAULT_FTP_PORT,_T("UserName"),_T("Password"),INTERNET_SERVICE_FTP,0,NULL);
Does any one have idea then please reply me urgently. Or is there any other idea to login to the FTP site with specific USERNAME & PASSWORD.
Thanks in advance.
Chirag.
|
|
|
|
|
I can't spot any obvious error, attached is the code I use sucessfully, I know it works on 95, 98, NT and XP.
The obvious question is what is the error return? I have removed my error trapping so you can see the wood for the trees!
m_hInetSession = InternetOpen(_T("FtpUpload"),<br />
INTERNET_OPEN_TYPE_PRECONFIG,<br />
NULL,<br />
NULL,<br />
INTERNET_INVALID_PORT_NUMBER);<br />
<br />
DWORD dwFlag = m_bPASVMOde ? INTERNET_FLAG_PASSIVE : 0;<br />
<br />
m_hFTPConnect = InternetConnect(m_hInetSession,<br />
strURL,<br />
(INTERNET_PORT) m_nPort,<br />
strUser,<br />
strPWD,<br />
INTERNET_SERVICE_FTP,<br />
dwFlag,<br />
NULL);
"Laughing at our mistakes can lengthen our own life. Laughing at someone else's can shorten it."
- Cullen Hightower
|
|
|
|
|
Thanks a lot for reply.
The error return is ErrorCode : 12014 i.e. The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect. Eventhough I am specifying correct password.
Regards,
Chirag.
|
|
|
|
|
You could try ravi's suggestion or my favourite use telnet and connect to port 21 then type
USER username
PASS mypassword
That way you can see what the server is sending
"Laughing at our mistakes can lengthen our own life. Laughing at someone else's can shorten it."
- Cullen Hightower
|
|
|
|
|
Hi, thanks for reply again.
I am now handling the situation in other way ... i.e. See my Code snippet below..
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.com",INTERNET_DEFAULT_FTP_PORT,NULL,NULL,INTERNET_SERVICE_FTP,0,NULL);
if (InternetSetOption(hIntConnect,INTERNET_OPTION_USERNAME,"UNIVERSE\\UserName",sizeof("UserName"))==FALSE)
int err=GetLastError();
if (InternetSetOption(hIntConnect,INTERNET_OPTION_PASSWORD,"Password",sizeof("Password"))==FALSE)
int err=GetLastError();
ret = FtpGetCurrentDirectory(hIntConnect,CurDir, &CurDirSize);
if (ret == FALSE)
int err=GetLastError();
ret = FtpSetCurrentDirectory(hIntConnect,"\kothi\cc");
if (ret == FALSE)
{
int err = GetLastError();
InternetGetLastResponseInfo(&nErr, sBuff, &nBuffLen);
}
The usually works fine except last action i.e. to Set the Current Working Directory. I am easily able to get the file from the root directory but not able to Set the Current working Directory.. The error i m getting id ErrorCode:12003.
Any Idea....that helps me a lot.
Thanks in advance.
Regards,
Chirag
|
|
|
|
|