|
Writing some code to allow an app to run correctly with right-to-left languages (e.g., Hewbrew, Arabic.)
For controls that need to be flipped (which is most, but not bitmaps and stuff like that), I add these styles:
WS_EX_LAYOUTRTL<br />
WS_EX_NOINHERITLAYOUT
My first try was to use SetWindowLong to set the style after the window was created.
This works like a champ in Windows 2000 and Windows XP. It doesn't work very well in Windows 98 - there are redraw problems. The windows stays gray until I move or resize, then controls get redrawn. If I do something like pop up a message box, it won't show up unless I open another app, and then switch back to my program!
After reading, I noticed that Microsoft says a lot of controls may not support changing this style at run-time, so I just pass the extended styles into CreateWindowEx . Same problems.
Any ideas? I could post code but it's pretty lengthy. I may play around some more and try to distill this into a small, simple GUI that breaks... but that's going to take some time.
Another note, I am trying this on an actual Windows Me Hebrew machine, as I know Windows Me English, switching to Hebrew, won't work.
I suppose I could do all the mirroring stuff myself, but that will suck. I'd like to avoid it if I can..
Thanks!
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
I have a custom file type for my application. When you click on one of these files it opens my application. I can put the path of the clicked file in the command line that Windows generates to open the application but where does this get passed to? How can I tell my application to open the file once it has happily opened itself?
I am using Visual C++ 6, MFC and a SDI with view/document.
If anyone knows how to do this please let me know as I am going crazy reading through useless MSDN pages.
|
|
|
|
|
check GetCommandLine() API
|
|
|
|
|
Just what I was looking for! Thanks
p
|
|
|
|
|
>> How can I tell my application to open the file once it has happily opened itself?
I find that question is very confusing.
In the MFC SDI document/view architecture any method used to open a file results in the CDocument::Serialize() method being called. What your application does in your override is entirely up to you.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
It was just getting the file path that was an issue. hspc pointed me in thr right direction.
|
|
|
|
|
Hi guys
I'm using
ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnClickList1)
to have control when I click on a CListCtrl (in Report Mode)
Once I'm inside the method, How can I know the item clicked?
void MyClass::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
ItemClicked=???
}
Best Regards
Doc
|
|
|
|
|
Try it.
If you click outside region of Item, the iItem will return -1, else, will return the index of item.
void MyClass::onclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW * pNMListView = (NM_LISTVIEW*)pNMHDR;
int iItem = ((NM_LISTVIEW*) pNMHDR)->iItem;
}
Enjoy it
Rodrigo Pinho Pereira de Souza
|
|
|
|
|
|
I have an application for which up to 4 instances of it can be fired up.
Now to close an instance of the application another application fires an named event; e.g. closeInstance3.
I use this piece of code for each application to determine what instance it is:
n = __argc;// and __argv
// if n > 1 then instance is specified, otherwise default to IDU 1
if (n > 1)
{
if(n == 2)
{
instanceID = 1;
}
if(n == 3)
{
instanceID = 2;
}
if(n == 4)
{
instanceID = 3;
}
if(n == 5)
{
instanceID = 4;
}
}
else
instanceID = 1; // default
This is because I use the following to start (in this instance 3)
GetStartupInfo(&si[2]);
CreateProcess(NULL, "c:\\Program Files\\Prog.exe 3 3 3", // Name of app to launch; 3 params of 3 = instance 3
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si[2], // Startup Information
&pi[2]); // Process information stored upon return
The main dialog accesses this variable via the following:
// The instance of this program( range 1 to 4)
extern int instanceID;
I have defined a class member as such:
volatile int m_nProgID;
My question is how do I have the thread which receives events (one of which will be to close this instance of the application) access this variable m_nProgID. I thought volatile would have worked?
Each instance of the program will define (or get a handle) for its close event; i.e. instance 2 will get a handle on event closeInstance2. They use m_nProgID in a switch to get a handle on the event they need to deal with; but it seems that m_nProgID is always 1 in the Thread that handles the events.
Instance 1 closes OK, but default for instanceID is 1. The other instances dont
grahamfff
|
|
|
|
|
Dear all,
To show a tooltip for my control, I used the most basic way; that is, calling the EnableToolTips() and handling the TTN_NEEDTEXT notification. However, my text is too long to be showed in a single line, so I want to break and show it in several lines. Please show me how to do it. I tried setting the maximum tooltip width via message TTM_SETMAXTIPWIDTH, but I failed. It does no effect !!! Thanks so much.
Best regards.
|
|
|
|
|
Hi
i am using CMemFile for MMF operation. i want to ensure that buffer size should be 4K. How to do this.
i think we can specify buffer size in the CreateFileMapping(). Is it correct?
Thanks in advance
ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
|
|
|
|
|
hi
i am trying to make a Client in VC++ for connecting to a Mysql Server
the problem is the connection is not Secure, if someone analyzes the network traffic when i using the Client he can Findout for example my username and password coz they are sent to server in plain text !!!
is there any way for me to make my connection Secure and Encrypted ?
thanx
|
|
|
|
|
|
Hi, I have a working spin control counting in hex. The problem is the format in which the hex is displayed.
Let me explain. The buddy edit-control displays '0x0000' and I need it to display '0x00'. How can I do this? Is there a function to format the buddy control?
Do I have to use the buddy control's member functions to .Get... the data( ie: 0x0000), alter it and then .Set... the data( ie: 0x00)?
Ideally, I'd like a know of any methods that set the format of the buddy control via the spin control's interface.
Thanks a bunch.
Carl
|
|
|
|
|
I have an app that creates a mutex (to ensure only one instance of it is running). While testing the app, it crashed without having the chance to go through its usual cleanup code (which includes a call to ReleaseMutex()). So, the mutex stayed in memory, and I couldn't re-launch my app without a reboot.
Surely there's better ways to get rid of an orphaned mutex?
|
|
|
|
|
Presuming an instance of your app is already running, it would prevent the second instance from starting up, which is probably working correctly, right?
How is it that you know the mutex is orphaned? I should think if a single instance of the app is running, the mutex would automatically be closed.
When a process terminates, it takes (almost) all the handles it created with it. This may not happen immediately nor with every type of handle. But for most, the system will automatically detect such a situation and do the cleanup.
Bikram Singh
|
|
|
|
|
> Presuming an instance of your app is already running, it would prevent the
> second instance from starting up, which is probably working correctly, right?
Yes. That's the whole reason I'm using mutexes in this app--one of the first things it does at startup is verify whether it can create a mutex. If it fails to do that, then it assumes another instance is already running, so it shuts down immediately so it won't interfere with the other copy's operations.
> How is it that you know the mutex is orphaned? I should think if a single
> instance of the app is running, the mutex would automatically be closed.
Microsoft's old WINOBJ.EXE says so. I can see my mutex under BaseNamedObjects still listed after my app dies.
> When a process terminates, it takes (almost) all the handles it created with
> it. This may not happen immediately nor with every type of handle. But for
> most, the system will automatically detect such a situation and do the
> cleanup.
That's what I was hoping, and has always been my assumption.
<edit>
It turns out that the situation is a little more convoluted than I first thought. It appears that another DLL elsewhere in the system obtained the mutex (through OpenMutex() rather than CreateMutex()), but never released it. That DLL is called by a service, and never got released. So, when the EXE shut down--cleanly or not--the mutex survived.
When I stopped the service, the DLL unloaded and the mutex died along with it. The problem was with the DLL--it tried to open the mutex, but never released it if it managed to open it...
Just so I can keep this in mind in the future--do you know of any situation were it is possible for a mutex to be *truly* orphaned?
|
|
|
|
|
No, but another thing you can try is to OPEN the mutex in your app, and if that fails, CREATE it.
If you can OPEN the mutex, you might try to wait on it for a very short while, and if you can, then you own it, and you do not have to 'release' it until your app quits or dies.
Now, if you open it and try to aquire the mutex, but you get MUTEX_ABANDONED return result, your previous instance is gone, even though the mutex still exists.
If you try to aquire it and get WAIT_FAILED, then something else still has hold of the mutex (probably another instance of your app). You can choose to wait a few seconds (if you are allowed) and try again, in case other instance is in process of shutting down.
By the way, you might want to also consider Josehp NEwcomer's dialog on the mutexes, because how you name it can have sever impact on muiutple isntances fo your progrma under terminal services and Widnows XP. You REALLY have to be careful to determine exactly what you want.
Anyhow, trying to aquire the mutex as well as open or create it might be better long run, in case another process, like a diagnostic tool, has a handle open to the mutex, but is not necessarily indicative of your specific process running (it should be unlikely an unknown application will attempt to aquire your mutex).
You TOTALLY must read this first...
http://www.flounder.com/nomultiples.htm
|
|
|
|
|
Thanks Blake. I've been using the method I've described for a good while and never really ran into any problem, but my usage scenarios have always been rather straightforward. I'll look into the URL you posted.
|
|
|
|
|
I am having a bit of trouble running CInternetFile::WriteString() and seeing results appear on the server file I am trying to change.
Here is a snipet of code that open the HTTP Connection, then opens a CInternetFile pointer then sends a request to write data (I hope). "strData" is the data I am sending.
<code>
pServer = session->GetHttpConnection("www.myserver.com", 80, "username", "password");
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/folder/file.txt");
pFile->SendRequestEx(strData.GetLength());
pFile->QueryInfoStatusCode(dwRet);
pFile->WriteString(strData);
pFile->EndRequest();
</code>
Does anyone see any problems with what I have here? I am kinda basing this off an example I found but the file I am trying to write to is not affected. The permissions on the file are set to a+rwx but I am wondering if there is something in the code I am missing or perhaps on the server. I can read from the file just fine. I just can't write to it.
Thanks!
|
|
|
|
|
In my program, I want to set some net configuration through a dialog, and I create a IP control in it with classwizad. but when I set the ip control's value or get it, there is always an error. I guess it is caused by that I don't initialize the control. then i use the create() function to initialize it, but it is still error. Why? how should i do.
|
|
|
|
|
give us a piece of your code...
TOXCCT >>> GEII power
|
|
|
|
|
I have just find the solution. It's so simple. but still thanks.
|
|
|
|
|
Hi all,
I have following code sample
SetLastError(0)
m_lpPrevWindowProc = SetWindowLong(m_MainWindowHandle,GWL_WNDPROC,(long)OnSubClassProc);
DWORd err = GetLastError() // err = 0;
the return value is negative, and i am not sure whether it is correct return code or a false return code.
Whether its a correct Return code or FALSe,
if its correct then why its giving negative value.
Thanks in Advance.
Abhishake
|
|
|
|
|