|
parims wrote:
But Date field is getting error .
And what would that error be?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
can anybody help me out for it???
thanks n regards
Supriya Tonape.
|
|
|
|
|
NetGroupGetUsers or use ActiveDirectory more directly if you have it.
Hint: MSDN search 'group users members enumerat*'
Steve S
Developer for hire!
|
|
|
|
|
thank u David It did help.bye.
Supriya Tonape
|
|
|
|
|
|
If Administrators is a local group, use NetLocalGroupGetMembers() . Otherwise if it is a global group, use NetGroupGetUsers() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I'm using CTabCtrl in my application.
It works fine except when I apply TCS_BOTTOM style.
In this case, tabs get align properly at bottom but no controls on tab pages are visible.
Can anybody help, it's very urgent.
Thanks in advance.
|
|
|
|
|
I read a raw(without file info head)file from the hard driver. raw file is a 1024x1024 8bit graylevel data. I put the data into a memory and draw it on a memDC and add some text on the memDC,then I want to use GetDlBits to get the raw data from memDC, but the data I get is always wrong with some bytes. So the raw image can not display correctly. But if I use memDC.GetPixel then the result is right.I can not find any problem, who can help me!!!
CBitmap memBitmap
CBitmap* pOldBmp=NULL ;
CDC memDC;
OldPal=NULL;
HDC hDC=pDC->GetSafeHdc();
CDIBDoc* pDoc=GetDocument();
BOOL bSuccess=FALSE;
if(pDoc->hDIB ==NULL)
{
AfxMessageBox("wrong");
return;
}
LPBYTE m_lpImage=(LPBYTE)GlobalLock(pDoc->hDIB);
if(pDoc->hDIB)
{
OldPal=pDC->SelectPalette(&m_Palette,FALSE);
if(OldPal==NULL)
{
AfxMessageBox("palette choose error");
}
if(pDC->RealizePalette()==GDI_ERROR)
{
AfxMessageBox("palette realize error");
}
}
else
{
AfxMessageBox("image datum are empty");
return ;
}
SetStretchBltMode(hDC,COLORONCOLOR);
memDC.CreateCompatibleDC(pDC);
memBitmap.CreateCompatibleBitmap(pDC,1024,1024);
pOldBmp = memDC.SelectObject(&memBitmap);
bSuccess=::StretchDIBits(memDC,0,0,1024,1024,
0, 0,1024, 1024,
m_lpImage,(LPBITMAPINFO)bmhdr,
DIB_RGB_COLORS,
SRCCOPY);
::SetBkMode(memDC,TRANSPARENT);
::SetTextColor(memDC,RGB(220, 220, 220));
CString str="DOG ";
CRect rect(20,20,70,50);
::DrawText(memDC,str,sizeof(str),rect,DT_LEFT|DT_WORDBREAK);
if(bSuccess==GDI_ERROR)
{
AfxMessageBox("error");
}
pDC->BitBlt(0,0,1024,1024,&memDC,0,0,SRCCOPY);
ZeroMemory(pDoc->pTemp, pDoc->dwBitsSize);
/*******************************wrong*************************/
int nCount = GetDIBits(memDC.GetSafeHdc(), (HBITMAP)memBitmap.m_hObject, 0, 1024,
pDoc->pTemp, (BITMAPINFO*)bmhdr, DIB_RGB_COLORS);
/*******************************test*************************/
if don't use GetDIBits but use these then right:
int nCount = memBitmap.GetBitmapBits(1024*1024,(LPVOID)pDoc->pTemp);
int i,j;
for (i=0;i<1024;i++)
{
for (j=0;j<1024;j++)
{
*(pDoc->pTemp+j*1024+i) = (BYTE)memDC.GetPixel(i,j);
}
}
|
|
|
|
|
why no one answer my question?
|
|
|
|
|
My be this is your problem:
Try CDibData[^] the notes I wrote in the source file covers every thing I know about its usage.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
|
Write a test program that just does what you are testing.
I have not (and will not) test what you have given. Your example is trying to do more than what you are asking about. You know the size of the bitmap, so why call StretchDIBits()? It looks like you're drawing some text on the DC, but then drawing the bitmap over that. etc...
Just write a simple program or a test function that just does what you are testing for and single step throu it with the debugger. That is how we solve the problems we face.
INTP
|
|
|
|
|
From my test I think GetDIBits can not be used for 8bits raw data. It can not get 8bits data from memDc correctly.
|
|
|
|
|
If the DC contains a bitmap, then it can get the data bits. Working with some GDI bitmap functions can be tricky, at least one of them just fails without telling you why (it just takes 1-bit, in the parameter data).
Examine CDibData.cpp and try to see what it is doing. May be you could write a test file for your data using it. If it fails then you are correct, and there is a bug I need to fix. Which would mean I (and others) have the same problem you do, and havn't fixed it yet.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I m coding my server socket using CSocket.Everything goes right till the Accept (function of CSocket) is called.it shows Debug Assertion failed in File:sockcore.cpp
here is my code
BOOL CCSocketDlg::OnInitDialog()
{...
//AfxSocketInit() has been called
//CCSocketApp::InitInstance()
//default constructor creates TCP/IP so it is SOCK_STREAM
//this function will also binds the the socket with one //network card
BOOL bsocketcreate= socket.Create(36545);//create the //socket which will listen at port 36545
//if the socket is not created
if(!bsocketcreate)
{
::OutputDebugString(_T("socket couldnot be created"));
return FALSE;
}
else
::OutputDebugString(_T("socket created successfully"));
//SOCKET created then start listen socket
BOOL bsocketlisten= socket.Listen(5);
//if the socket is not able to listen at specified port
if(!bsocketlisten)
{
::OutputDebugString(_T("socket couldnot listen on specified port"));
return FALSE;
}
else
::OutputDebugString(_T("socket listens at specified port"));
// Begin the Socket thread
AfxBeginThread(fnMainThread,LPVOID(this));
return TRUE; // return TRUE unless you set the focus to a control
}
UINT fnMainThread(LPVOID p)
{
CCSocketDlg *m_Dlg=(CCSocketDlg*)p;
//create another CSocket variable to accept the connection
CSocket sockConnection;
//socket is listening it can know accept new connection
BOOL bsocketaccept=m_Dlg->socket.Accept(sockConnection);
if(!bsocketaccept)//if the connection with client is not //establish
{
::AfxMessageBox(_T("socket couldnot establish new connection with client"));
AfxEndThread(0);//end thread
return 1;
}
::OutputDebugString(_T("connection accepted on new socket"));
//Begin a new Socket thread AfxBeginThread(fnMainThread,LPVOID(p));
m_Dlg->socket.Close();
return 0;
}
thanx for help
-- modified at 4:10 Friday 26th August, 2005
|
|
|
|
|
1) try to change m_Dlg->socket.Accept(sockConnection); as
m_Dlg->socket.Accept(*sockConnection);
2) Or change CSocket sockconnection as CSocket* sockconnection = new CSocket()
redindian
|
|
|
|
|
i tried but same Debug Assertion has occurred
|
|
|
|
|
if i ignore the Debug Assertion then my server socket is connected to client and after that my program crashes.
|
|
|
|
|
Sunit,
This is repetetive problem when you use Windows Socket programing in Windows Operating system. As you know, MFC use asyncronous connection calls and request for scoket processing, MFC uses windows messagess for every new requests, data received etc...
Your problem is, you are created Windows socket in one thread, but using it on another thread. Bascially they will send messages which is irrelavant to another thread, hence assertion.
They are two appraches to solve this problem...
1. Create your server socket on UINT fnMainThread(LPVOID p) function. If you look at your function, there is no message handling is done. So you have to create a socket then you need to implement the message loop also for that thread.
2. When you use different thread for socket handling and creation,
first detach your socket handle from the main thread using Detach() method, copy that reference of socket and attach that reference to the new server socket object in another thread...
Please let me know if you need more help....
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
thanx for ur help
but still i want to clarify my doubts
what does asynchronous connection(used by MFC) means
|
|
|
|
|
asynchronous is used to avoid the blocking of the program.
Suppose you have a server socket which is waiting for a client to conenct,
it will stop the execution and waiting for a client to join. When a client joins, it will continue to next line..
To Avoid this Windows use asynchronous call. When a client connects, MFC will send a windows message, which you can come to know that one client has connected and you have to Accept the client..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
i m creating Socket in main thread but using it in a worker thread .as worker thread doesnot handle the window messages so when MFC sends message for Client connection the my CSocket::Accept(which is another thread)cannot accept it.
m i right
thanx in advance
-- modified at 10:25 Friday 26th August, 2005
|
|
|
|
|
Hi, I suggest a redesign of your networking program:
1) use CAsyncSocket instead of CSocket
2) do all socket operations in one thread context, be event based instead of starting multiple worker threads for each socket
3) when implementing a server (not just multiple clients) then spend your program a list of incoming socket objects, something like std::list<casyncsocket*>. Here you store socket objects for house keeping and cleanup.
4) do a lot of testing. check against buffer overruns, code injection, etc
Hope it helps,
Moak
|
|
|
|
|
I want to automate Excel in MFC . I can automate a new application but how can i modify existing Excel File programmaticaly through those interfaces. Can some body help me how can I load existing file:
Here is the code:-
_Application app; // app is the Excel _Application object
// Start Excel and get Application object...
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel.");
}
else
{
//Make Excel Visible and display a message
app.SetVisible(TRUE);
}
Can some1 plz tell me how to load a specific file ???
Regards
|
|
|
|
|
This is relatively easy, once you're familiar with the Excel object model. Of course, MS give most information for VB developers, but it isn't too hard.
Firstly, from the application object, get the Workbooks collection. From there, you can access already open workbooks, create new ones in the collection (but not necessarily save them to disk) and open existing files.
The method from the workbooks collection you want is 'Open'. This lets you open an existing file. From there, again, you can get the workbook itself (Workbooks Item) and from there the worksheet, and work with ranges etc. Then you can call the Workbook (the item not the collection) save method to write your changes.
Check out by searching for XLCLIENT in MSDN, and "Excel automation VC++" too. There is information in there, you just have to find it.
The hardest part is that in VB examples you see stuff like
set wb = application.workbooks("test1.xls")
and you have to figure out how to convert that to C++.
There was a useful tool which takes VB code in and spits out C++ stuff specifically for this purpose on the MS site, but I can never find it. It wasn't perfect but helped a lot.
Essentially, for any method that returns an object (like workbooks Item), you will need a corresponding wrapper object to hold the returned object, and then call it's methods, so it gets a bit long-winded.
One other caveat is that for a lot of methods, there will be arguments you don't want to specify, but cannot leave out, so you will need to construct a VARIANT for this purpose.
COleVariant v;
v.vt = VT_ERROR;
v.scode = DISP_E_PARAMNOTFOUND;
You can then pass v for optional args you don't want.
I tend to use #import on the type libraries, which does a similar thing to the MFC generation, but I find simpler to use.
Hope this helps.
Steve S
Developer for hire!
|
|
|
|
|