|
I need some words int outputted text (DrawTextEx(..)) be bold!
|
|
|
|
|
Could you reply an example of the input and outputs texts, as you want them, please ?!
TOXCCT >>> GEII power
|
|
|
|
|
Send me a BIG THANX in my mailbox and i will write a custom function for you to accomplish ur work.
I will basically use Textout with some formatting that you want (word wrap etc.).
If you can write it on ur own, go ahead... lol
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi,
I am trying to make my class thread safe with out much luck and wonder if anybody can point me in the right direction. An object of this class is shared between 2 threads, therefore I have added some critical sections but in testing this does not seem to be enough, below is what i have so far:
void CPacket::Lock()
{
CSingleLock singleLock(&m_CList);
singleLock.Lock();
ASSERT(singleLock.IsLocked());
}
void CPacket::Unlock()
{
CSingleLock singleLock(&m_CList);
singleLock.Unlock();
ASSERT(!singleLock.IsLocked());
}
and in my code around all use of the object:
m_capturedPacket->Lock();
m_capturedPacket->Addpacket()
m_capturedPacket->Unlock();
Internally the class mainatins a CList which is being corrupted, how can I make calls to this class thread safe?
|
|
|
|
|
The CSingleLock class unlocks the object in its destructor. Your Lock() function locks the critical section, and then when the CSingleLock object is destroyed when the Lock() function returns, the critical section is unlocked.
Try changing your code to this:
void CPacket::Lock(){
m_CList.Lock();
ASSERT(m_CList.IsLocked());
}
void CPacket::Unlock(){
m_CList.Unlock();
ASSERT(!m_CList.IsLocked());
}
Software Zen: delete this;
|
|
|
|
|
Hi all,
I use this class for an icon in the systemtray, and I added some extra code for extra features...
http://www.codeproject.com/shell/systemtray.asp?target=tray%7Cicon&df=100&forumid=88&app=50
Now the strange thing is that it gives lots of errors like 'NIIF_INFO' : undeclared identifier
when I debug the application.
But when I build the application, no errors are shown and it really builds & runs the application!
Strange huh??
How can I solve this problem, because I want to build my project in Debug mode too!
I already set _WIN32_IE 0x0500 in stdafx.h
Thanks!
Geert
|
|
|
|
|
hi,all:
i'm writing a service,and create a windows in login desktop.i can see the windows in spy trace.but the trace show the window proc is unavailable and the window can not receive msg from remote another service.the service type is SERVICE_INTERACTIVE_PROCESS.who can tell me why?
void CTsapiWnd::DoCreate()
{
CreateEx(0,AfxRegisterWndClass (CS_GLOBALCLASS),"tsapimsg2", 0, 0,0,0, 0,0, 0, 0);
}
in service:
BOOL ShowMsgDlg()
{
hwinstaCurrent = GetProcessWindowStation();
if (hwinstaCurrent == NULL){
LogEvent(_T("get window station err"),0,FALSE);
//return FALSE;
}
hdeskCurrent = GetThreadDesktop(GetCurrentThreadId());
if (hdeskCurrent == NULL){
LogEvent(_T("get window desktop err"),0,FALSE);
//return FALSE;
}
hwinsta = OpenWindowStation("winsta0", FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS |
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE |
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN |
WINSTA_WRITEATTRIBUTES);
if (hwinsta == NULL)
{
LogEvent(_T("open window station err"),0,FALSE);
//return FALSE;
}
if (!SetProcessWindowStation(hwinsta))
{
LogEvent(_T("Set window station err"),0,FALSE);
//return FALSE;
}
hdesk = OpenDesktop("default", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hdesk == NULL)
{
LogEvent(_T("Open desktop err"),0,FALSE);
//return FALSE;
}
SetThreadDesktop(hdesk);
m_TsapiWndPtr=new CTsapiWnd;
m_TsapiWndPtr->DoCreate();
if (!SetProcessWindowStation(hwinstaCurrent))
return FALSE;
if (!SetThreadDesktop(hdeskCurrent))
return FALSE;
if (!CloseWindowStation(hwinsta))
return FALSE;
if (!CloseDesktop(hdesk))
return FALSE;
return TRUE;
}
|
|
|
|
|
Could it be security issue?
|
|
|
|
|
|
Hi,
I need a proper way of keeping a window maximized all the time.
On startup its quite easy, I just call:
ShowWindow(SW_SHOWMAXIMIZED);
But the problem is if the user minimizes the window and then
reopens it, then it wont be maximized again.
Thank you for your help
Mario
|
|
|
|
|
in the oninitdialog resize the window using setwindowpos(...).
|
|
|
|
|
ok
you can use following code buddy
add window handller WM_SIZE ok
void OnSize( UINT nType, int cx, int cy ){
if(nType==SIZE_MINIMIZED)
{
}else
{
this->ShowWindow(SW_SHOW_MAXIMIZED);
}
}
ok that very simple
Alok Gupta
visit me at http://alok.stormpages.com
|
|
|
|
|
Hi all...
How can i know the type of Internet connection such as ISDN,Direct connection or 56.6kbps modem etc used by a client.
|
|
|
|
|
Hello,
I am writing a application in Visual C++ .NET 7.0. I'd like to keep my classes in seperate files to keep things organized, but I am having difficulty accessing classes from within two files. Can someone help me find a solution accessing between files in this manner? I need to access methods and data back and forth in this manner, but I don't want the two classes to be in the same file. What am I doing wrong? Is there a different way to do this?
Here is a simplified version:
Class1.h
#ifndef __Class1H__
#define __Class1H__
#include "Class2.h"
class Class1
{
public:
Class1();
~Class1();
//This doesn't work because it is in a different file!
Class1(Class2* object);
//This doesn't work because it is in a different file!
Class2 obj;
};
#endif // __Class1H__
Class2.h
#ifndef __Class2H__
#define __Class2H__
//this is causing problems...
#include "Class1.h"
class Class2
{
public:
Class2();
~Class2();
};
#endif // __Class2H__
Class1.cpp
#include "Class1.h"
Class1::Class1()
{
}
Class1::~Class1()
{
}
Class2.cpp
#include "Class2.h"
Class2::Class2()
{
}
Class2::~Class2()
{
}
|
|
|
|
|
first, why do you call #include "Class1.h" into Class2.h when Class2 dont use any object from Classe 1 ??
So, do this :
Class1.h
<font style="color:blue;">#include</font> <font style="color:gray;">"Class2.h"</font>;
<font style="color:blue;">class</font> Class1;
<font style="color:blue;">class</font> Class1 {
Class2 MyClass2Object;
<font style="color:green;">
}
Class2.h
<font style="color:blue;">class</font> Class2;
<font style="color:blue;">class</font> Class2 {
<font style="color:green;">
}
there won't have any recursive call problem anymore...
i forgot to say, don't put the data members into public: statement... prefer this for the interface (member functions which are allowed for the users).
TOXCCT >>> GEII power
|
|
|
|
|
oh, i see another problem...
each header file must be "included" once into the project. for that, you must use preprocessor directive to exclude recursive redifinitions :
Class1.h
<font style="color:blue;">#if</font> !<font style="color:blue;">defined</font>(__CLASS1_H_INCLUDED__)
<font style="color:blue;">#define</font> __CLASS1_H_INCLUDED__
<font style="color:green;">
<font style="color:blue;">#endif</font><font style="color:green;">//__CLASS1_H_INCLUDED__</font>
Class2.h
<font style="color:blue;">#if</font> !<font style="color:blue;">defined</font>(__CLASS2_H_INCLUDED__)
<font style="color:blue;">#define</font> __CLASS2_H_INCLUDED__
<font style="color:green;">
<font style="color:blue;">#endif</font><font style="color:green;">//__CLASS2_H_INCLUDED__</font>
that concern only .h files. don't forget !
TOXCCT >>> GEII power
|
|
|
|
|
sir,
I need a code to get a selected text from any window to the clipboard and I would like to know how windows implements cltr+c for copying a selected text from any window.
|
|
|
|
|
//copy
CString str="alok"
if (::OpenClipboard(AfxGetApp()->m_pMainWnd->GetSafeHwnd())) {
if(::EmptyClipboard()) {
if (::SetClipboardData(CF_TEXT,str) == NULL ) {
AfxMessageBox( "Unable to set Clipboard data" );
} } }
CloseClipboard();
//paste
CString str;
if (OpenClipboard()) str=GetClipboardData(CF_TEXT);
CloseClipboard();
that willl help you lot
Alok Gupta
visit me at http://alok.stormpages.com
|
|
|
|
|
Have a txt file that looks like this
2345
5332
4433
4343
5555
6666
....
Want to read and write it to another text file like this (3 columns)
2345 5332 4433
4343 5555 6666
using c++ (non MFC)
any help will be greatly appreciated
|
|
|
|
|
openinfile();
openoutfile();
int i = 0;
while(!endoffile)
{
readfrominfile;
writetooutfile;
i++;
if(i==3)
{
write '\n' to out file;
i = 0;
}
}
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Hi,
I'm interested in writing a program that must keep track of the current active window.
I would like to get messages from the OS that tells me when the user switches from app to app.
What is the best way to do this?
Should I use a WM_TIMER and just check what process the current active window belongs to?
(actually, I don't know exactly what function I should use to find the current active window and process)
Or is there a way to hook into something that would notify me on changes?
Samples, comments would be wonderful!
Thanks,
Dave
|
|
|
|
|
To use SetWindowsHookEx() to get it!
|
|
|
|
|
what are those commands whose type is similar to "AFX_IDP_COMMAND_FAILURE"?
When to use it?
|
|
|
|
|
I have a function that responds to a message by incrementing a counter variable by 1:
OnAction(WPARAM wParam, LPARAM lParam)<br />
{<br />
m_nCounter += 1;<br />
}
The message that it responds to is posted twice using PostMessage, once immediately after the other (like so):
::PostMessage(GetSafeHwnd(),WM_ACTION,0,0);<br />
::PostMessage(GetSafeHwnd(),WM_ACTION,0,0);<br />
The strange thing is that if i modify the function to display a MessageBox with the value of the counter (like so):
OnAction(WPARAM wParam, LPARAM lParam)<br />
{<br />
CString string;<br />
m_nCounter += 1;<br />
string.Format("%d",m_nCounter);<br />
MessageBox(string);<br />
}
I get two message boxes, as I should; however the values in the message boxes are 2 then 1, not 1 then 2.
Howcome I am receiving 2 then 1, rather than 1 then 2 from the message boxes as you would expect?
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
both the message box comes on together?
as far as i know, message boxes in certain events could be very tough way of debuging the app coz the message boxes starts pumping the messages, so other messages too gets executed.
try TRACE instead.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|