当前,当我显示我的用户名(通过会话)和注销功能时,两者都位于不同的行
图片:http://prntscr.com/nc2v1b(此为输出)
我想要的是:https://prnt.sc/nc2w23
用户名位于“注销”的右侧
答案 0 :(得分:1)
首先,删除此部分// Mouse hook
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0) // do not process the message
return CallNextHookEx(NULL, nCode,
wParam, lParam);
if (WM_LBUTTONDOWN == wParam)
{
OutputDebugString(L"\n Left button down \n");
_rclick_activated = false;
SetTimer(m_windowHandle, // handle to main window
IDT_TIMER1, // timer identifier
2000, // 2-second interval
(TIMERPROC)NULL); // no timer callback
}
else if (WM_LBUTTONUP == wParam)
{
OutputDebugString(L"\n Left button up \n");
if (_rclick_activated)
{
MOUSEINPUT mouseData = {};
mouseData.dx = GET_X_LPARAM(lParam);
mouseData.dy = GET_Y_LPARAM(lParam);
mouseData.dwFlags = MOUSEEVENTF_RIGHTDOWN;
INPUT inputData = {};
inputData.type = INPUT_MOUSE;
inputData.mi = mouseData;
UINT result = SendInput(1, &inputData, sizeof(INPUT));
if (result == 1)
{
OutputDebugString(L"\n successfully insert right button down \n");
}
}
}
else if (WM_RBUTTONDOWN == wParam)
{
OutputDebugString(L"\n Right button down \n");
if (_rclick_activated)
{
MOUSEINPUT mouseData = {};
mouseData.dx = GET_X_LPARAM(lParam);
mouseData.dy = GET_Y_LPARAM(lParam);
mouseData.dwFlags = MOUSEEVENTF_RIGHTUP;
INPUT inputData = {};
inputData.type = INPUT_MOUSE;
inputData.mi = mouseData;
UINT result = SendInput(1, &inputData, sizeof(INPUT));
if (result == 1)
{
OutputDebugString(L"\n successfully insert right button up \n");
}
_rclick_activated = false;
}
}
else if (WM_RBUTTONUP == wParam)
{
OutputDebugString(L"\n Right button up \n");
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
//...
// Rigister mouse hook
HHOOK m_msgHook = SetWindowsHookEx(WH_MOUSE, MouseProc, NULL, GetCurrentThreadId());
//...
//...
case WM_TIMER:
// process the 2-second timer
_rclick_activated = true;
KillTimer(hWnd, IDT_TIMER1);
return 0;
//...
使用style='float:right;'
将使文本右移。
第二,这里需要一些间距:
float:right
答案 1 :(得分:0)
向右浮动则将所有内容推向右侧(最后一项是最右侧的一项)。 如果您需要将所有内容都放在一行,那么您的代码似乎可以正常工作。
<?php
session_start(); // Right at the top of your script
?>
<li class='active'>
<?php
if($_SESSION['logged']==true)
{
echo '<a href="logout.php"><span>Logout</span></a>' . $_SESSION["username"];
}
else
{
echo '<a href="registerform.html"><span>Login/Register</span></a>';
}
echo '</li>';
?>